microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
384 stars 247 forks source link

Using all analyzers in pipeline #489

Closed MJECloud closed 5 years ago

MJECloud commented 5 years ago

Hey Freddy,

we are using all three code analyzers in our workspace in development. In our build and release pipeline we would also like to get all warnings and errors from all analyzers.

Looking into the Compile-AppInNAVContainer function, we only see an option to run the CodeCop analyzer, not the other two. Besides that, we don't know if warnings would be displayed while building, because so far we have got none when running the pipeline.

Does the navcontainerhelper offer functionality for that, and if so does it show all warnings by default?

freddydk commented 5 years ago

You should use the ruleset feature and specify the ruleset you want to use in -rulesetfile https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-rule-set-syntax-for-code-analysis-tools

MJECloud commented 5 years ago

Ok, thank you.

But can you use all the analyzers in navcontainerhelper or only the codecop? Seems like you only invoke the alc.exe with the "/analyzer ...CodeCop.dll".

freddydk commented 5 years ago

You specify the analyzers in the ruleset (as I understand it)

MJECloud commented 5 years ago

So does this .dll include all analyzers (AppSourceCop, UICop and CodeCop)

https://github.com/microsoft/navcontainerhelper/blob/659f15b505a19623f139af2065444ebbb9367ced/AppHandling/Compile-AppInNavContainer.ps1#L271

Or do you have to specify them separately?

freddydk commented 5 years ago

I think that was the "old" way of enabling an analyzer - now (I think) ALC reads the analyzers you enable in the ruleset (without having to specify DLLs) I don't know for sure though.

RafaelKoch commented 5 years ago

The ruleset file is used to alter the behavior of given rules and is optional. It does not specify which analyzers to use. That is done in either the workspace settings or the app settings. It looks like that:

    "settings": {
        "al.enableCodeAnalysis": true,
        "al.codeAnalyzers": [
            "${CodeCop}",
            "${AppSourceCop}",
            "${UICop}"
        ],

navcontainerhelper seems to call alc with a reference to one of the three DLL. This looks odd to us.

Anyway, it does also not work in our pipeline even so. When we try to provoke a warning that should fire in the basic CodeCop (which appears to be used) no warning surfaces in the build step.

Not sure if we handle this properly or if there is still a problem elsewhere. And if elsewhere, is it navcontainerhelper... But we have to start somewhere :-)

freddydk commented 5 years ago

I will check with the team.

freddydk commented 5 years ago

Team confirmed that I need to enable analyzers like the codecop - then the ruleset determines what happens with the result. I will add parameters for the various analyzers and add a -addallanalyzers, which basically will enumerate DLLs in the analyzers folder and add them all. This way you can add individual or all analyzers.

freddydk commented 5 years ago

On the other hand - it doesn't make sense to have a Run All. AppSourceCop and PerTenantExtensionCop are likely not to run at the same time.

freddydk commented 5 years ago

0.6.1.4 is published with these parameters.

RafaelKoch commented 5 years ago

Tested with success.

Worth noting: it appears that just the level "error" surfaces. Warnings must be raised to error level if they are required to stop a build. Will try that later.

But whatever the result, THIS issue can be closed.