Skip to content

Commit

Permalink
Merge branch 'development' into prerelease
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanMaron committed Jan 22, 2022
2 parents 7322c32 + f2ca0bf commit 56c923f
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
uses: actions/cache@v2
with:
path: ALLanguage.vsix
key: vsix-19.2.32968.34478
key: vsix-19.3.34541.35210
- name: Download platform artifact
if: steps.cache-vsix.outputs.cache-hit != 'true'
run: Invoke-WebRequest https://bcartifacts.blob.core.windows.net/sandbox/19.2.32968.34478/platform -OutFile platform.zip
run: Invoke-WebRequest https://bcartifacts.azureedge.net/sandbox/19.3.34541.35210/platform -OutFile platform.zip
- name: Unzip platform
if: steps.cache-vsix.outputs.cache-hit != 'true'
run: 7z x platform.zip *.vsix -r
Expand Down
1 change: 1 addition & 0 deletions BusinessCentral.LinterCop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DebugType>portable</DebugType>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
Expand Down
8 changes: 4 additions & 4 deletions Design/Rule0003DoNotUseObjectIDsInVariablesOrProperties.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using Microsoft.Dynamics.Nav.CodeAnalysis;
using Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics;
using Microsoft.Dynamics.Nav.CodeAnalysis.Syntax;
using System;
using System.Collections.Immutable;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;

namespace BusinessCentral.LinterCop.Design
Expand Down Expand Up @@ -92,7 +89,10 @@ private void CheckForObjectIDsInVariablesOrProperties(SyntaxNodeAnalysisContext

if (ctx.Node.GetLocation().SourceSpan.End == parameter.DeclaringSyntaxReference.GetSyntax(CancellationToken.None).Span.End)
{
correctName = GetCorrectName(parameter.ParameterType.NavTypeKind.ToString(), parameter.ParameterType.ToString());
if (parameter.ParameterType.NavTypeKind == NavTypeKind.Array)
correctName = ((IArrayTypeSymbol)(parameter.ParameterType)).ElementType.Name.ToString();
else
correctName = GetCorrectName(parameter.ParameterType.NavTypeKind.ToString(), parameter.ParameterType.ToString());

if (ctx.Node.ToString().Trim('"').ToUpper() != correctName.ToUpper())
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0003DoNotUseObjectIDsInVariablesOrProperties, ctx.Node.GetLocation(), new object[] { ctx.Node.ToString().Trim('"'), correctName }));
Expand Down
15 changes: 8 additions & 7 deletions Design/Rule0015PermissionSetCoverage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
using Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics;
using System;
using System.Collections.Immutable;
using Microsoft.Dynamics.Nav.Analyzers.Common.AppSourceCopConfiguration;
using Microsoft.Dynamics.Nav.Analyzers.Common;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using System.Xml.XPath;

namespace BusinessCentral.LinterCop.Design {
namespace BusinessCentral.LinterCop.Design
{
[DiagnosticAnalyzer]
class Rule0015PermissionSetCoverage : DiagnosticAnalyzer {
class Rule0015PermissionSetCoverage : DiagnosticAnalyzer
{
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create<DiagnosticDescriptor>(DiagnosticDescriptors.Rule0015PermissionSetCoverage);

public override void Initialize(AnalysisContext context)
Expand Down Expand Up @@ -39,7 +40,7 @@ private void CheckPermissionSetCoverage(SymbolAnalysisContext context)
{
ISymbol current = enumerator.Current;
IApplicationObjectTypeSymbol appObjTypeSymbol = (IApplicationObjectTypeSymbol)current;
PermissionObjectKind permObjectKind = PermissionObjectKind.TableData;
PermissionObjectKind permObjectKind = PermissionObjectKind.Table;
int permObjectId = appObjTypeSymbol.Id;

switch (appObjTypeSymbol.NavTypeKind)
Expand All @@ -57,7 +58,7 @@ private void CheckPermissionSetCoverage(SymbolAnalysisContext context)
permObjectKind = PermissionObjectKind.Report;
break;
case NavTypeKind.Table:
permObjectKind = PermissionObjectKind.TableData;
permObjectKind = PermissionObjectKind.Table;
break;
case NavTypeKind.XmlPort:
permObjectKind = PermissionObjectKind.Xmlport;
Expand All @@ -68,12 +69,12 @@ private void CheckPermissionSetCoverage(SymbolAnalysisContext context)
{
continue;
}
if (permissionSymbols.Contains((permObjectKind, permObjectId)) || XmlPermissionExistsForObject(permissionSetDocuments, permObjectKind, permObjectId))
if (permissionSymbols.Contains((permObjectKind, permObjectId)) || permissionSymbols.Contains((permObjectKind, 0)) || XmlPermissionExistsForObject(permissionSetDocuments, permObjectKind, permObjectId))
{
continue;
}

context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0015PermissionSetCoverage, current.GetLocation(), new Object[] { appObjTypeSymbol.NavTypeKind.ToString(), appObjTypeSymbol.Name }));
context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0015PermissionSetCoverage, current.GetLocation(), new Object[] { permObjectKind.ToString(), appObjTypeSymbol.Name }));
}
}

Expand Down
44 changes: 43 additions & 1 deletion LinterCopAnalyzers.resx
Original file line number Diff line number Diff line change
Expand Up @@ -119,129 +119,171 @@
</resheader>
<data name="AnalyzerPrefix" xml:space="preserve">
<value>LC</value>
<comment/>
</data>
<data name="Rule0001FlowFieldsShouldNotBeEditableDescription" xml:space="preserve">
<value>FlowFields should not be editable.</value>
<comment/>
</data>
<data name="Rule0001FlowFieldsShouldNotBeEditableFormat" xml:space="preserve">
<value>FlowFields should not be editable.</value>
<comment/>
</data>
<data name="Rule0001FlowFieldsShouldNotBeEditableTitle" xml:space="preserve">
<value>FlowFields should not be editable.</value>
<comment/>
</data>
<data name="Rule0002CommitMustBeExplainedByCommentDescription" xml:space="preserve">
<value>Commit() needs a comment to justify its existance. Either a leading or a trailing comment.</value>
<comment/>
</data>
<data name="Rule0002CommitMustBeExplainedByCommentFormat" xml:space="preserve">
<value>Commit() needs a comment to justify its existance. Either a leading or a trailing comment.</value>
<comment/>
</data>
<data name="Rule0002CommitMustBeExplainedByCommentTitle" xml:space="preserve">
<value>Commit() needs a comment to justify its existance. Either a leading or a trailing comment.</value>
<comment/>
</data>
<data name="Rule0003DoNotUseObjectIDsInVariablesOrPropertiesDescription" xml:space="preserve">
<value>Do not use an Object ID for properties or variables declaration.</value>
<comment/>
</data>
<data name="Rule0003DoNotUseObjectIDsInVariablesOrPropertiesFormat" xml:space="preserve">
<value>Do not use an Object ID for properties or variables declaration. Use {1} instead.</value>
<comment/>
</data>
<data name="Rule0003DoNotUseObjectIDsInVariablesOrPropertiesTitle" xml:space="preserve">
<value>Do not use an Object ID for properties or variables declaration.</value>
<comment/>
</data>
<data name="Rule0004LookupPageIdAndDrillDownPageIdDescription" xml:space="preserve">
<value>Property "LookupPageID" and "DrilldownPageID" must be filled in table because it is used in list page</value>
<comment/>
</data>
<data name="Rule0004LookupPageIdAndDrillDownPageIdFormat" xml:space="preserve">
<value>Property "LookupPageID" and "DrilldownPageID" must be filled in table "{1}" because it is used in page "{2}" (list)</value>
<comment/>
</data>
<data name="Rule0004LookupPageIdAndDrillDownPageIdTitle" xml:space="preserve">
<value>Property "LookupPageID" and "DrilldownPageID" must be filled in table because it is used in list page</value>
<comment/>
</data>
<data name="Rule0005VariableCasingShouldNotDIfferFromDeclarationDescription" xml:space="preserve">
<value>Wrong casing detected!</value>
<comment/>
</data>
<data name="Rule0005VariableCasingShouldNotDIfferFromDeclarationFormat" xml:space="preserve">
<value>Wrong casing detected! Use {0} instead.</value>
<comment/>
</data>
<data name="Rule0005VariableCasingShouldNotDIfferFromDeclarationTitle" xml:space="preserve">
<value>Wrong casing detected!</value>
<comment/>
</data>
<data name="Rule0006FieldNotAutoIncrementInTemporaryTableDescription" xml:space="preserve">
<value>AutoIncrement fields are not possible in temporary tables!</value>
<comment/>
</data>
<data name="Rule0006FieldNotAutoIncrementInTemporaryTableFormat" xml:space="preserve">
<value>AutoIncrement fields are not possible in temporary tables!</value>
<comment/>
</data>
<data name="Rule0006FieldNotAutoIncrementInTemporaryTableTitle" xml:space="preserve">
<value>AutoIncrement fields are not possible in temporary tables!</value>
<comment/>
</data>
<data name="Rule0007DataPerCompanyShouldAlwaysBeSetDescription" xml:space="preserve">
<value>DataPerCompany is missing!</value>
<comment/>
</data>
<data name="Rule0007DataPerCompanyShouldAlwaysBeSetFormat" xml:space="preserve">
<value>DataPerCompany is missing!</value>
<comment/>
</data>
<data name="Rule0007DataPerCompanyShouldAlwaysBeSetTitle" xml:space="preserve">
<value>DataPerCompany is missing!</value>
<comment/>
</data>
<data name="Rule0008NoFilterOperatorsInSetRangeDescription" xml:space="preserve">
<value>Filter operators should not be used in SetRange. Use SetFilter instead.</value>
<comment/>
</data>
<data name="Rule0008NoFilterOperatorsInSetRangeFormat" xml:space="preserve">
<value>Filter operators should not be used in SetRange. Use SetFilter instead.</value>
<comment/>
</data>
<data name="Rule0008NoFilterOperatorsInSetRangeTitle" xml:space="preserve">
<value>Filter operators should not be used in SetRange. Use SetFilter instead.</value>
<comment/>
</data>
<data name="Rule0009CodeMetricsInfoDescription" xml:space="preserve">
<value>Cyclomatic complexity and Maintainability index</value>
<comment/>
</data>
<data name="Rule0009CodeMetricsInfoFormat" xml:space="preserve">
<value>Cyclomatic complexity: {0}, Maintainability index: {1}</value>
<comment/>
</data>
<data name="Rule0009CodeMetricsInfoTitle" xml:space="preserve">
<value>Cyclomatic complexity and Maintainability index</value>
<comment/>
</data>
<data name="Rule0011AccessPropertyShouldAlwaysBeSetDescription" xml:space="preserve">
<value>Access property is missing!</value>
<comment/>
</data>
<data name="Rule0011AccessPropertyShouldAlwaysBeSetFormat" xml:space="preserve">
<value>Access property is missing!</value>
<comment/>
</data>
<data name="Rule0011AccessPropertyShouldAlwaysBeSetTitle" xml:space="preserve">
<value>Access property is missing!</value>
<comment/>
</data>
<data name="Rule0012DoNotUseObjectIdInSystemFunctionsDescription" xml:space="preserve">
<value>Wrong Parameter detected.</value>
<comment/>
</data>
<data name="Rule0012DoNotUseObjectIdInSystemFunctionsFormat" xml:space="preserve">
<value>Wrong Parameter detected. Select the correct object with "{0}::" instead.</value>
<comment/>
</data>
<data name="Rule0012DoNotUseObjectIdInSystemFunctionsTitle" xml:space="preserve">
<value>Wrong Parameter detected.</value>
<comment/>
</data>
<data name="Rule0013CheckForNotBlankOnSingleFieldPrimaryKeysDescription" xml:space="preserve">
<value>NotBlank should be set explicitly for tables with a single-field primary key.</value>
<comment/>
</data>
<data name="Rule0013CheckForNotBlankOnSingleFieldPrimaryKeysTitle" xml:space="preserve">
<value>NotBlank should be set explicitly for tables with a single-field primary key.</value>
<comment/>
</data>
<data name="Rule0013CheckForNotBlankOnSingleFieldPrimaryKeysFormat" xml:space="preserve">
<value>NotBlank should be set explicitly for tables with a single-field primary key.</value>
<comment/>
</data>
<data name="Rule0014PermissionSetCaptionLengthDescription" xml:space="preserve">
<value>The Caption of permissionset objects should not exceed the maximum length.</value>
<comment/>
</data>
<data name="Rule0014PermissionSetCaptionLengthFormat" xml:space="preserve">
<value>The Caption of permissionset objects should not exceed {0} characters. Use MaxLength={0} or Locked=true to ensure there are no translations that exceed this limit.</value>
<comment/>
</data>
<data name="Rule0014PermissionSetCaptionLengthTitle" xml:space="preserve">
<value>The Caption of permissionset objects should not exceed the maximum length.</value>
<comment/>
</data>
<data name="Rule0015PermissionSetCoverageDescription" xml:space="preserve">
<value>All application objects should be covered by at least one permission set in the extension.</value>
<comment/>
</data>
<data name="Rule0015PermissionSetCoverageFormat" xml:space="preserve">
<value>The application object {0} {1} is not covered by any permission set in the extension.</value>
<value>The application object {0} "{1}" is not covered by any permission set in the extension.</value>
<comment/>
</data>
<data name="Rule0015PermissionSetCoverageTitle" xml:space="preserve">
<value>All application objects should be covered by at least one permission set in the extension.</value>
Expand Down

0 comments on commit 56c923f

Please sign in to comment.