Skip to content

Commit

Permalink
Rule0011 modifications
Browse files Browse the repository at this point in the history
Added helper files
Increased Version
  • Loading branch information
StefanMaron committed Oct 14, 2021
1 parent b7c6d68 commit 0c700bd
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 6 deletions.
6 changes: 3 additions & 3 deletions AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
//[assembly: Extension]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.17")]
[assembly: AssemblyInformationalVersion("0.17")]
[assembly: AssemblyVersion("0.17")]
[assembly: AssemblyFileVersion("0.18")]
[assembly: AssemblyInformationalVersion("0.18")]
[assembly: AssemblyVersion("0.18")]
15 changes: 13 additions & 2 deletions Design/Rule0011AccessPropertyShouldAlwaysBeSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics;
using System;
using System.Collections.Immutable;
using BusinessCentral.LinterCop.Helpers;

namespace BusinessCentral.LinterCop.Design
{
Expand All @@ -15,10 +16,20 @@ public override void Initialize(AnalysisContext context)

private void CheckForMissingAccessProperty(SymbolAnalysisContext context)
{
if (context.Symbol.GetProperty(PropertyKind.Access) == null)
if (context.Symbol.Kind == SymbolKind.Field)
{
context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0011AccessPropertyShouldAlwaysBeSet, context.Symbol.GetLocation()));
LinterSettings.Create();
if (LinterSettings.instance.enableRule0011ForTableFields)
{
context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0011AccessPropertyShouldAlwaysBeSet, context.Symbol.GetLocation()));
}
}
else
if (context.Symbol.GetProperty(PropertyKind.Access) == null)
{
context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0011AccessPropertyShouldAlwaysBeSet, context.Symbol.GetLocation()));
}

}
}
}
1 change: 1 addition & 0 deletions Helpers/LinterSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class LinterSettings
{
public int cyclomaticComplexetyThreshold = 8;
public int maintainablityIndexThreshold = 20;
public bool enableRule0011ForTableFields = false;
static public LinterSettings instance;

static public void Create()
Expand Down
5 changes: 5 additions & 0 deletions LinterCop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cyclomaticComplexetyThreshold": 8,
"maintainablityIndexThreshold": 20,
"enableRule0011ForTableFields": false
}
50 changes: 50 additions & 0 deletions LinterCop.ruleset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "LinterCopRuleset",
"description": "These are the default rules of the linter cop. You can use this file as a template to start from",
"rules": [
{
"id": "LC0001",
"action": "Warning"
},
{
"id": "LC0002",
"action": "Warning"
},
{
"id": "LC0003",
"action": "Warning"
},
{
"id": "LC0004",
"action": "Warning"
},
{
"id": "LC0005",
"action": "Warning"
},
{
"id": "LC0006",
"action": "Error"
},
{
"id": "LC0007",
"action": "Hidden"
},
{
"id": "LC0008",
"action": "Warning"
},
{
"id": "LC0009",
"action": "Hidden"
},
{
"id": "LC0010",
"action": "Warning"
},
{
"id": "LC0011",
"action": "Hidden"
}
]
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ These are the default values:
``` json
{
"cyclomaticComplexetyThreshold": 8,
"maintainablityIndexThreshold": 20
"maintainablityIndexThreshold": 20,
"enableRule0011ForTableFields": false
}
```

Expand Down

0 comments on commit 0c700bd

Please sign in to comment.