Closed cegekaJG closed 2 months ago
You are using a ruleset and specify two different paths:
"rulesetFile": "BC14.ruleset.json",
and
"al.ruleSetPath": "../BC14.ruleset.json",
Make sure that the relative path is correct for vscode.
Both of them are correct - the paths are relative to the config files respectively, and .github/AL-Go-settings.json
is located in a subfolder in the repository root. I can tell because other modified rule behavior is being applied to VSC.
Can you repro with the latest compiler? This repo is for dealing with issues on teh latest compiler version including and emphasizing the pre-release version.
I've tried it both on v12.6.936426
(which is the latest version according to the VS Code Extension and v14.0.956192 (pre-release)
.
In both cases, the violation was ignored, both during analysis and compilation.
I can not reproduce this.
Are there any AL related settings inside your user settings.json or the folder settings.json?
According to your workspace file your directory structure is the following:
/root/BC14.ruleset.json
/root/foo/al.code-workspace
/root/foo/Base/
/root/foo/.github/AL-Go-settings.json
...
Is this correct?
Not quite - the structure is as follows:
root/
├ .github/
| └ AL-Go-settings.json
├ Base/
| └ app.json
├ BC14.ruleset.json
└ al.code-workspace
I've gotten the two properties confused in my earlier comment. The AL extension has root/Base
as it's CWD, whereas the AL Go pipeline uses root
.
I don't have any .vscode/settings.json
files, and these are my user settings:
{
"[al]": {
"editor.tabSize": 4
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[markdown]": {
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint"
},
"[powershell]": {
"editor.defaultFormatter": "ms-vscode.powershell"
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnType": true
},
"[xml]": {
"editor.defaultFormatter": "DotJoshJohnson.xml"
},
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml"
},
"al.enableCodeActions": true,
"alOutline.addDataItemToReportColumnName": true,
"alOutline.addToolTipsToPageFields": false,
"alOutline.codeActionsOnSave": [
"SortVariables",
"SortProperties",
"FormatDocument"
],
"alOutline.codeCleanupActions": [
"ConvertObjectIdsToNames",
"RemoveStrSubstNoFromError",
"RemoveWithStatements",
"RemoveEmptyTriggers",
"RemoveEmptySections",
"RemoveBeginEnd",
"RemoveUnusedVariables",
"SortVariables",
"SortProperties",
"FixKeywordsCase",
"MakeFlowFieldsReadOnly",
"FixIdentifiersCase",
"AddApplicationAreas",
"AddTableFieldCaptions",
"RefreshToolTips",
"AddToolTips",
"AddMissingParentheses",
"TrimTrailingWhitespace",
"RemoveEmptyLines"
],
"alOutline.fixCaseRemovesQuotesFromDataTypeIdentifiers": true,
"alOutline.fixCodeCopMissingParenthesesOnSave": true,
"alOutline.openDefinitionInNewTab": true,
"black-formatter.args": [
"--line-length",
"80"
],
"cSpell.enableFiletypes": [
"!json",
"!code-workspace"
],
"cSpell.userWords": [
"Cegeka",
"ruleset"
],
"diffEditor.ignoreTrimWhitespace": false,
"editor.accessibilitySupport": "off",
"editor.bracketPairColorization.independentColorPoolPerBracketType": true,
"editor.defaultFormatter": "ms-dynamics-smb.al",
"editor.fontSize": 16,
"editor.formatOnSave": true,
"editor.rulers": [
80
],
"editor.suggestSelection": "first",
"editor.tabSize": 2,
"errorLens.enabledDiagnosticLevels": [
"warning",
"info"
],
"explorer.confirmDelete": false,
"explorer.confirmDragAndDrop": false,
"explorer.confirmPasteNative": false,
"files.autoSave": "afterDelay",
"git.autofetch": true,
"git.confirmSync": false,
"git.enableSmartCommit": true,
"git.openRepositoryInParentFolders": "always",
"git.pruneOnFetch": true,
"githubPullRequests.assignCreated": "${user}",
"githubPullRequests.defaultMergeMethod": "squash",
"githubPullRequests.fileListLayout": "tree",
"githubPullRequests.notifications": "pullRequests",
"githubPullRequests.pullBranch": "always",
"githubPullRequests.pullRequestDescription": "Copilot",
"githubPullRequests.pushBranch": "always",
"githubPullRequests.remotes": [
"origin"
],
"gitlens.advanced.blame.customArguments": [
"-CC"
],
"gitlens.advanced.fileHistoryFollowsRenames": true,
"gitlens.advanced.messages": {
"suppressCommitHasNoPreviousCommitWarning": true
},
"gitlens.ai.experimental.openai.model": "gpt-4-1106-preview",
"gitlens.ai.experimental.provider": "openai",
"gitlens.blame.ignoreWhitespace": true,
"gitlens.defaultDateShortFormat": "D MMM, YYYY",
"gitlens.defaultTimeFormat": "H:mm",
"json.schemas": [
{
"fileMatch": [
"/.github/AL-Go-Settings.json"
],
"url": "https://raw.githubusercontent.com/microsoft/AL-Go/main/Schema/algoreposettingssyntax.json"
},
{
"fileMatch": [
"/.AL-Go/settings.json"
],
"url": "https://raw.githubusercontent.com/microsoft/AL-Go/main/Schema/algosettingssyntax.json"
}
],
"markdown.extension.toc.levels": "2..6",
"NAB.IncludeTablesAndFieldsInDocs": true,
"powershell.promptToUpdatePowerShell": false,
"python.analysis.stubPath": "",
"security.workspace.trust.untrustedFiles": "open",
"todo-tree.general.tags": [
"BUG",
"HACK",
"FIXME",
"TODO",
"XXX",
"[ ]",
"[x]"
],
"todo-tree.regex.regex": "(//|#|<!--|;|/\\*|^|^\\s*(-|\\d+.))\\s*($TAGS)",
"todohighlight.keywords": [],
"vsicons.dontShowNewVersionMessage": true,
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"window.menuBarVisibility": "compact",
"window.title": "${dirty}${rootName}",
"workbench.colorCustomizations": {},
"workbench.iconTheme": "vscode-icons",
"XLF: Empty": true,
"XLF: Empty Local Translation": true,
"XLF: Search": "",
"XLF: State": false
}
In your workspace file you have "al.ruleSetPath": "../BC14.ruleset.json",
so it will go back one directory (starting from the folder of the workspace file) and look for BC14.ruleset.json
there.
Can you try to put just "BC14.ruleset.json"
and do a Reload window
or just restart vsc.
I tried that earlier, I got an error:
An error occurred while loading the included rule set file c:\root\Base\BC14.ruleset.json - Could not find file 'c:\root\Base\BC14.ruleset.json'.
I've also tried removing the custom ruleset entirely, and the compiler still didn't report the violation. By default, the rule action isn't hidden, so it should at least provide a warning. Additionally, all other customizations to the rule severity are being applied correctly, so I don't think the ruleset is the problem.
I probably found the problem:
UserId
, GuiAllowed
, etc. are allowed to be called without parenthesis:
see https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/system/system-guiallowed-method):
This method can be invoked using property access syntax.
The newest compiler (e.g. Microsoft (R) AL Compiler version 12.6.14.18950
) does not warn (or even emit AA0008) on these calls.
The compiler used on your pipeline Microsoft (R) AL Compiler version 3.0.5.47103
does still emit this diagnostic.
To be sure you could install the old compiler and test this theory.
Edit: Just test this with a normal procedure:
trigger OnRun()
begin
Message(UserId); // no error/warning
MyProcedure; // error/warning
end;
local procedure MyProcedure()
begin
end;
Is this an error or did the rules change? The article on AA0008 doesn't mention anything about exceptions.
We may update the documentation but we will probably not fix issues that are on the old unsupported versions of the al compiler. @dannoe thanks for the investigation
1. Describe the bug When working with a BC14 extension, the rule
AA0008
is ignored both by Visual Studio Code and the compiler when building the application locally. However, when building the application using AL Go, the compiler does correctly detect rule violations.2. To Reproduce Steps to reproduce the behavior:
app.json
.github/AL-Go-settings.json
.AL-Go/settings.json
al.code-workspace
Sample page extension:
3. Expected behavior
For Visual Studio Code, violations of AA0008 should be highlighted when opening the AL Object in the editor. For our projects, we use a custom ruleset that escalates the severity of
AA0008
from "Warning" to "Error".When compiling locally, the build should result in failure, reporting a violation of
AA0008
.When compiling using the AL Go Build pipeline, the build should result in failure, reporting a violation of
AA0008
. So while it's possible to compile the BC14 locally, the Build pipeline of AL Go will encounter an error. Projects using other versions of BC (22, 23) do not encounter this problem.4. Actual behavior
The violation (
UserId
isn't followed by parentheses()
) isn't highlighted by Visual Studio Code.No rule violations are detected by the compiler, and the package is created successfully.
Edit: Doing further experimentation, I noticed that only select functions don't cause a violation. These are the ones I've noticed so far:
5. Versions:
v12.6.936426
14.21.46103.0
ms-dynamics-smb.al