Skip to content

Commit

Permalink
#744 LC0068 Do not warn on 20 Mio tables
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanMaron committed Sep 3, 2024
1 parent d767567 commit 86bf4a8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
1 change: 1 addition & 0 deletions BusinessCentral.LinterCop.Test/Rule0068.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public async Task HasDiagnostic(string testCase)
#if Fall2023RV1
[TestCase("ProcedureCallsPermissionsPropertyFullyQualified")]
#endif
[TestCase("IntegerTable")]
public async Task NoDiagnostic(string testCase)
{
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "NoDiagnostic", $"{testCase}.al"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
codeunit 50000 MyCodeunit
{
trigger OnRun()
var
Integer: Record Integer;
begin
[|Integer.FindFirst();|]
end;
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@ private void AnalyzeInternalProcedures(SyntaxNodeAnalysisContext ctx)
if (ctx.IsObsoletePendingOrRemoved()) return;

if (ctx.ContainingSymbol.GetContainingObjectTypeSymbol().DeclaredAccessibility != Accessibility.Public) return;

MethodDeclarationSyntax methodDeclarationSyntax = (MethodDeclarationSyntax)ctx.Node;
SyntaxNodeOrToken accessModifier = methodDeclarationSyntax.ProcedureKeyword.GetPreviousToken();

if (accessModifier.Kind == SyntaxKind.LocalKeyword || accessModifier.Kind == SyntaxKind.InternalKeyword) return;

if (methodDeclarationSyntax.GetLeadingTrivia().Where(x => x.Kind == SyntaxKind.SingleLineDocumentationCommentTrivia).Any()) return;

ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0025InternalProcedureModifier, methodDeclarationSyntax.ProcedureKeyword.GetLocation()));
if (!ctx.Node.IsKind(SyntaxKind.MethodDeclaration)) return;

try
{
MethodDeclarationSyntax methodDeclarationSyntax = (MethodDeclarationSyntax)ctx.Node;
SyntaxNodeOrToken accessModifier = methodDeclarationSyntax.ProcedureKeyword.GetPreviousToken();
if (accessModifier.Kind == SyntaxKind.LocalKeyword || accessModifier.Kind == SyntaxKind.InternalKeyword) return;
if (methodDeclarationSyntax.GetLeadingTrivia().Where(x => x.Kind == SyntaxKind.SingleLineDocumentationCommentTrivia).Any()) return;
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0025InternalProcedureModifier, methodDeclarationSyntax.ProcedureKeyword.GetLocation()));
}
catch (System.InvalidCastException)
{
return;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ private bool ProcedureHasInherentPermission(IEnumerable<IAttributeSymbol> inhere

private void CheckProcedureInvocation(IPropertySymbol objectPermissions, ITypeSymbol variableType, char requestedPermission, Action<Diagnostic> ReportDiagnostic, Microsoft.Dynamics.Nav.CodeAnalysis.Text.Location location, ITableTypeSymbol targetTable)
{
if (targetTable.Id > 2000000000) return;
if (TableHasInherentPermission(targetTable, requestedPermission)) return;

if (objectPermissions == null)
Expand Down

0 comments on commit 86bf4a8

Please sign in to comment.