1
1
using System . Collections . Generic ;
2
- using System . Linq ;
3
2
using Rubberduck . Inspections ;
4
3
using Rubberduck . SettingsProvider ;
5
4
6
5
namespace Rubberduck . Settings
7
6
{
8
7
public interface ICodeInspectionConfigProvider
9
8
{
10
- CodeInspectionSettings Create ( IEnumerable < IInspection > inspections ) ;
9
+ CodeInspectionSettings Create ( ) ;
11
10
CodeInspectionSettings CreateDefaults ( ) ;
12
11
void Save ( CodeInspectionSettings settings ) ;
13
12
}
14
13
15
14
public class CodeInspectionConfigProvider : ICodeInspectionConfigProvider
16
15
{
17
16
private readonly IPersistanceService < CodeInspectionSettings > _persister ;
18
- private IEnumerable < IInspection > _inspections ;
19
17
20
18
public CodeInspectionConfigProvider ( IPersistanceService < CodeInspectionSettings > persister )
21
19
{
22
20
_persister = persister ;
23
21
}
24
22
25
- public CodeInspectionSettings Create ( IEnumerable < IInspection > inspections )
23
+ public CodeInspectionSettings Create ( )
26
24
{
27
- if ( inspections == null ) return null ;
28
-
29
- _inspections = inspections ;
30
- var prototype = new CodeInspectionSettings ( GetDefaultCodeInspections ( ) , new WhitelistedIdentifierSetting [ ] { } ) ;
31
- return _persister . Load ( prototype ) ?? prototype ;
25
+ var prototype = new CodeInspectionSettings ( GetDefaultCodeInspections ( ) , new WhitelistedIdentifierSetting [ ] { } ) ;
26
+ return _persister . Load ( prototype ) ?? prototype ;
32
27
}
33
28
34
29
public CodeInspectionSettings CreateDefaults ( )
35
30
{
36
- //This sucks.
37
- return _inspections != null
38
- ? new CodeInspectionSettings ( GetDefaultCodeInspections ( ) , new WhitelistedIdentifierSetting [ ] { } )
39
- : null ;
31
+ //This no longer sucks.
32
+ return new CodeInspectionSettings ( GetDefaultCodeInspections ( ) , new WhitelistedIdentifierSetting [ ] { } ) ;
40
33
}
41
34
42
35
public void Save ( CodeInspectionSettings settings )
@@ -46,9 +39,47 @@ public void Save(CodeInspectionSettings settings)
46
39
47
40
public HashSet < CodeInspectionSetting > GetDefaultCodeInspections ( )
48
41
{
49
- return new HashSet < CodeInspectionSetting > ( _inspections . Select ( x =>
50
- new CodeInspectionSetting ( x . Name , x . Description , x . InspectionType , x . DefaultSeverity ,
51
- x . DefaultSeverity ) ) ) ;
42
+ //*This* sucks now.
43
+ return new HashSet < CodeInspectionSetting >
44
+ {
45
+ new CodeInspectionSetting ( "ObjectVariableNotSetInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Suggestion , CodeInspectionSeverity . Suggestion ) ,
46
+ new CodeInspectionSetting ( "FunctionReturnValueNotUsedInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Warning , CodeInspectionSeverity . Warning ) ,
47
+ new CodeInspectionSetting ( "SelfAssignedDeclarationInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Hint , CodeInspectionSeverity . Hint ) ,
48
+ new CodeInspectionSetting ( "MoveFieldCloserToUsageInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Suggestion , CodeInspectionSeverity . Suggestion ) ,
49
+ new CodeInspectionSetting ( "EncapsulatePublicFieldInspection" , string . Empty , CodeInspectionType . MaintainabilityAndReadabilityIssues , CodeInspectionSeverity . Suggestion , CodeInspectionSeverity . Suggestion ) ,
50
+ new CodeInspectionSetting ( "EmptyStringLiteralInspection" , string . Empty , CodeInspectionType . LanguageOpportunities , CodeInspectionSeverity . Warning , CodeInspectionSeverity . Warning ) ,
51
+ new CodeInspectionSetting ( "ImplicitActiveSheetReferenceInspection" , string . Empty , CodeInspectionType . MaintainabilityAndReadabilityIssues , CodeInspectionSeverity . Warning , CodeInspectionSeverity . Warning ) ,
52
+ new CodeInspectionSetting ( "ImplicitActiveWorkbookReferenceInspection" , string . Empty , CodeInspectionType . MaintainabilityAndReadabilityIssues , CodeInspectionSeverity . Warning , CodeInspectionSeverity . Warning ) ,
53
+ new CodeInspectionSetting ( "MultipleFolderAnnotationsInspection" , string . Empty , CodeInspectionType . MaintainabilityAndReadabilityIssues , CodeInspectionSeverity . Error , CodeInspectionSeverity . Error ) ,
54
+ new CodeInspectionSetting ( "ProcedureCanBeWrittenAsFunctionInspection" , string . Empty , CodeInspectionType . LanguageOpportunities , CodeInspectionSeverity . Suggestion , CodeInspectionSeverity . Suggestion ) ,
55
+ new CodeInspectionSetting ( "UseMeaningfulNameInspection" , string . Empty , CodeInspectionType . MaintainabilityAndReadabilityIssues , CodeInspectionSeverity . Suggestion , CodeInspectionSeverity . Suggestion ) ,
56
+ new CodeInspectionSetting ( "WriteOnlyPropertyInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Suggestion , CodeInspectionSeverity . Suggestion ) ,
57
+ new CodeInspectionSetting ( "UntypedFunctionUsageInspection" , string . Empty , CodeInspectionType . LanguageOpportunities , CodeInspectionSeverity . Hint , CodeInspectionSeverity . Hint ) ,
58
+ new CodeInspectionSetting ( "AssignedByValParameterInspection" , string . Empty , CodeInspectionType . LanguageOpportunities , CodeInspectionSeverity . Warning , CodeInspectionSeverity . Warning ) ,
59
+ new CodeInspectionSetting ( "ConstantNotUsedInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Warning , CodeInspectionSeverity . Warning ) ,
60
+ new CodeInspectionSetting ( "DefaultProjectNameInspection" , string . Empty , CodeInspectionType . MaintainabilityAndReadabilityIssues , CodeInspectionSeverity . Suggestion , CodeInspectionSeverity . Suggestion ) ,
61
+ new CodeInspectionSetting ( "ImplicitPublicMemberInspection" , string . Empty , CodeInspectionType . MaintainabilityAndReadabilityIssues , CodeInspectionSeverity . Hint , CodeInspectionSeverity . Hint ) ,
62
+ new CodeInspectionSetting ( "MultilineParameterInspection" , string . Empty , CodeInspectionType . MaintainabilityAndReadabilityIssues , CodeInspectionSeverity . Suggestion , CodeInspectionSeverity . Suggestion ) ,
63
+ new CodeInspectionSetting ( "NonReturningFunctionInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Error , CodeInspectionSeverity . Error ) ,
64
+ new CodeInspectionSetting ( "ObsoleteCallStatementInspection" , string . Empty , CodeInspectionType . LanguageOpportunities , CodeInspectionSeverity . Suggestion , CodeInspectionSeverity . Suggestion ) ,
65
+ new CodeInspectionSetting ( "ObsoleteGlobalInspection" , string . Empty , CodeInspectionType . LanguageOpportunities , CodeInspectionSeverity . Suggestion , CodeInspectionSeverity . Suggestion ) ,
66
+ new CodeInspectionSetting ( "ObsoleteLetStatementInspection" , string . Empty , CodeInspectionType . LanguageOpportunities , CodeInspectionSeverity . Suggestion , CodeInspectionSeverity . Suggestion ) ,
67
+ new CodeInspectionSetting ( "ObsoleteTypeHintInspection" , string . Empty , CodeInspectionType . LanguageOpportunities , CodeInspectionSeverity . Suggestion , CodeInspectionSeverity . Suggestion ) ,
68
+ new CodeInspectionSetting ( "OptionBaseInspection" , string . Empty , CodeInspectionType . MaintainabilityAndReadabilityIssues , CodeInspectionSeverity . Hint , CodeInspectionSeverity . Hint ) ,
69
+ new CodeInspectionSetting ( "ParameterCanBeByValInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Suggestion , CodeInspectionSeverity . Suggestion ) ,
70
+ new CodeInspectionSetting ( "ParameterNotUsedInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Warning , CodeInspectionSeverity . Warning ) ,
71
+ new CodeInspectionSetting ( "ProcedureNotUsedInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Warning , CodeInspectionSeverity . Warning ) ,
72
+ new CodeInspectionSetting ( "UnassignedVariableUsageInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Error , CodeInspectionSeverity . Error ) ,
73
+ new CodeInspectionSetting ( "VariableNotUsedInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Warning , CodeInspectionSeverity . Warning ) ,
74
+ new CodeInspectionSetting ( "VariableNotAssignedInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Warning , CodeInspectionSeverity . Warning ) ,
75
+ new CodeInspectionSetting ( "ImplicitByRefParameterInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Hint , CodeInspectionSeverity . Hint ) ,
76
+ new CodeInspectionSetting ( "ImplicitVariantReturnTypeInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Hint , CodeInspectionSeverity . Hint ) ,
77
+ new CodeInspectionSetting ( "MultipleDeclarationsInspection" , string . Empty , CodeInspectionType . MaintainabilityAndReadabilityIssues , CodeInspectionSeverity . Warning , CodeInspectionSeverity . Warning ) ,
78
+ new CodeInspectionSetting ( "ObsoleteCommentSyntaxInspection" , string . Empty , CodeInspectionType . LanguageOpportunities , CodeInspectionSeverity . Suggestion , CodeInspectionSeverity . Suggestion ) ,
79
+ new CodeInspectionSetting ( "OptionExplicitInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Error , CodeInspectionSeverity . Error ) ,
80
+ new CodeInspectionSetting ( "VariableTypeNotDeclaredInspection" , string . Empty , CodeInspectionType . LanguageOpportunities , CodeInspectionSeverity . Warning , CodeInspectionSeverity . Warning ) ,
81
+ new CodeInspectionSetting ( "MalformedAnnotationInspection" , string . Empty , CodeInspectionType . CodeQualityIssues , CodeInspectionSeverity . Error , CodeInspectionSeverity . Error )
82
+ } ;
52
83
}
53
84
}
54
85
}
0 commit comments