Skip to content

[Bug]: enableCodeAnalyzersOnTestApps: false does not disable customCodeCops for test/BCPT apps under Workspace Compilation (CompileApps action) #2319

Description

AL-Go version

9.1

Describe the issue

When a project uses "workspaceCompilation": { "enabled": true }, the CompileApps action (CompileApps/Compile.ps1 + .Modules/CompileFromWorkspace.psm1) correctly disables the built-in code analyzers (CodeCop, AppSourceCop, PTECop, UICop) for test app and BCPT test app folders when enableCodeAnalyzersOnTestApps is false. However, it does not disable custom analyzers configured via customCodeCops for those same folders. As a result, custom analyzer DLLs keep running against test apps even though the setting says they shouldn't.

Expected behavior

With enableCodeAnalyzersOnTestApps: false, no analyzers (neither built-in cops nor custom cops) should run against testFolders / bcptTestFolders during compilation - matching the documented setting description ("the code analyzers will be enabled when building test apps as well") and the existing behavior of the classic Run-AlPipeline container pipeline.

Steps to reproduce

  1. Configure a project with "customCodeCops": [ ... ] and "enableCodeAnalyzersOnTestApps": false (default).
  2. Enable "workspaceCompilation": { "enabled": true } at the repo or project level.
  3. Add a test app folder (testFolders) that would trigger one of the custom analyzer rules if it ran.
  4. Run CI/CD (or the CompileApps action directly).
  5. Observe the custom analyzer diagnostic/warning/error still appears for the test app, even though enableCodeAnalyzersOnTestApps is false.

Additional context (logs, screenshots, etc.)

Root cause (AI Driven - Sonnet 5)

CompileApps/Compile.ps1 (v9.1)

$buildParams = @{
    ...
    Analyzers       = (Get-CodeAnalyzers -Settings $settings)
    CustomAnalyzers = (Get-CustomAnalyzers -Settings $settings -CompilerFolder $compilerFolder)
}


if ($testFoldersToBuild.Count -gt 0) {
    if (-not ($settings.enableCodeAnalyzersOnTestApps)) {
        $buildParams.Analyzers = @()      # <-- only Analyzers is cleared
    }
    $testAppFiles = Build-AppsInWorkspace @buildParams -Folders $testFoldersToBuild -OutFolder $testAppOutputFolder -AppType 'testApp'
}

if ($bcptTestFoldersToBuild.Count -gt 0) {
    if (-not ($settings.enableCodeAnalyzersOnTestApps)) {
        $buildParams.Analyzers = @()      # <-- same issue here
    }
    $bcptTestAppFiles = Build-AppsInWorkspace @buildParams -Folders $bcptTestFoldersToBuild -OutFolder $testAppOutputFolder -AppType 'bcptApp'
}

$buildParams.CustomAnalyzers is set once, before the app-folder compile step, and is never reset/cleared for the test or BCPT branches.

.Modules/CompileFromWorkspace.psm1 -> CompileAppsInWorkspace

Confirms CustomAnalyzers is passed straight through to alc.exe workspace compile ... --customanalyzers ... with no enableCodeAnalyzersOnTestApps awareness at all:

if ($CustomAnalyzers -and $CustomAnalyzers.Count -gt 0) {
    $arguments += "--customanalyzers"
    $arguments += ($CustomAnalyzers -join ",")
}

Suggested fix (AI Driven - Sonnet 5)

In CompileApps/Compile.ps1, when enableCodeAnalyzersOnTestApps is false, also clear $buildParams.CustomAnalyzers alongside $buildParams.Analyzers in both the testFoldersToBuild and bcptTestFoldersToBuild branches:

if (-not ($settings.enableCodeAnalyzersOnTestApps)) {
    $buildParams.Analyzers = @()
    $buildParams.CustomAnalyzers = @()
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Fix ReadyFix ReadyIn PreviewCurrently available in AL-Go for GitHub previewShippedFeature is included in the latest versionbugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions