Code Monkey home page Code Monkey logo

Comments (28)

StefanMaron avatar StefanMaron commented on August 18, 2024 2

I added the info message in v0.15. But I decided to make the info message disabled by default as it can generate a huge amount of messages. Just set it to info in a custom rule set to enable it.

Warning message will fowllow

from businesscentral.lintercop.

StefanMaron avatar StefanMaron commented on August 18, 2024 2

Do you have "al.enableCodeAnalysis": true in settings?

from businesscentral.lintercop.

jwikman avatar jwikman commented on August 18, 2024 2

For Halstead volume I am still not sure what would be the operators used to calculate it.

Hi @StefanMaron, what did you decide to use for Halstead Volume?
It could be really helpful to get some more insights into how both Cyclomatic complexity and Maintainability index are calculated by this rule, when you are trying to improve your score.

Maybe it could deserve it's own .md file with documentation? (That might useful for every rule, actually 😀)

from businesscentral.lintercop.

StefanMaron avatar StefanMaron commented on August 18, 2024 1

Short answer: Yes, I am planning to integrate both again.

As you already stated, its not possible to do it the same way as it was in the AL Linter. Since I can only display messages when given conditions are met. So I see two options here:

  1. Always show the values of maintainability Index and cyclomatic complexity on every procedure and trigger as an Info message
  2. Make some kind of config file similar to the AppSource.json and set a threshold for both values and show a warning if those are reached

from businesscentral.lintercop.

StefanMaron avatar StefanMaron commented on August 18, 2024 1

Yes, I think I just can do both and hide the info if the warning shows up. I would also split it in two rules to each can be turned off separately

from businesscentral.lintercop.

StefanMaron avatar StefanMaron commented on August 18, 2024 1

from businesscentral.lintercop.

lvanvugt avatar lvanvugt commented on August 18, 2024 1

image

from businesscentral.lintercop.

StefanMaron avatar StefanMaron commented on August 18, 2024 1

They should show up between other warnings or if you have error lens, right behind the function in code
image
image

from businesscentral.lintercop.

StefanMaron avatar StefanMaron commented on August 18, 2024 1

Glad to hear it works :)
I will update the readme later to make the install a bit clearer

from businesscentral.lintercop.

StefanMaron avatar StefanMaron commented on August 18, 2024 1

I did not add the plus 1. 😅 but that will be an easy one

from businesscentral.lintercop.

StefanMaron avatar StefanMaron commented on August 18, 2024 1

Yes exactly I need some default values in case no config is in place.
So the default value for warnings to start appear is when either cyclomatic complexity reaches 8 or greater or when maintainability index reaches 20 or lower

from businesscentral.lintercop.

lvanvugt avatar lvanvugt commented on August 18, 2024

BTW2: the same applies to Maintainability Index.

from businesscentral.lintercop.

lvanvugt avatar lvanvugt commented on August 18, 2024

Can 1 and 2 be combined? I.e., when the threshold is reached color the info or the function name (the latter likewise AL Test Runner does in relation to the outcome of a test run).

from businesscentral.lintercop.

StefanMaron avatar StefanMaron commented on August 18, 2024

I searched a bit for a reasonable way of calculating those values and this one seems to be okay:
https://radon.readthedocs.io/en/latest/intro.html

For cyclomatic complexity it seems to be just a counting of decisions in a given code block.
Mapping the list in the document to al statements which would each add +1 to the complexity:

  • if
  • else if
  • for
  • while
  • boolean operators (and/or)
  • case lines
  • until

For Halstead volume I am still not sure what would be the operators used to calculate it.

from businesscentral.lintercop.

lvanvugt avatar lvanvugt commented on August 18, 2024

I searched a bit for a reasonable way of calculating those values and this one seems to be okay: https://radon.readthedocs.io/en/latest/intro.html

Great

For Halstead volume I am still not sure what would be the operators used to calculate it.

I have not gone into this myself.

from businesscentral.lintercop.

lvanvugt avatar lvanvugt commented on August 18, 2024

When will it be available?

from businesscentral.lintercop.

StefanMaron avatar StefanMaron commented on August 18, 2024

Info message is available now. And I will try to also implement the warning this week. I will keep you updated here

from businesscentral.lintercop.

lvanvugt avatar lvanvugt commented on August 18, 2024

Not realy.
image

from businesscentral.lintercop.

lvanvugt avatar lvanvugt commented on August 18, 2024

How to enable the info message?

from businesscentral.lintercop.

StefanMaron avatar StefanMaron commented on August 18, 2024

First of all you need to have the code cop in you settings:

"al.codeAnalyzers": [
    "${CodeCop}",
    "${UICop}",
    "${analyzerfolder}BusinessCentral.LinterCop.dll" <== this one
],

then you should already see some warnings in your code.
To enable the info message you need to activate the rule via custom rule set:
https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-rule-set-syntax-for-code-analysis-tools
this is my setting:
"al.ruleSetPath": "./my.ruleset.json"

and within I have my rules adjusted:

{
    "name": "Name",
    "description": "Description",
    "rules": [
        {
            "id": "LC0001",
            "action": "Hidden",
            "justification": "Justification"
        },
        {
            "id": "LC0009",
            "action": "Info",
            "justification": "Justification"
        }
    ]
}

Could be that you need to reload VS Code after setting this up

from businesscentral.lintercop.

lvanvugt avatar lvanvugt commented on August 18, 2024

All set. Now where should I be able to see the info message regarding cyclometric complexity? Don't seem to find anything yet.

from businesscentral.lintercop.

lvanvugt avatar lvanvugt commented on August 18, 2024

Doesn't show at all. Any way to check things in the background?

from businesscentral.lintercop.

lvanvugt avatar lvanvugt commented on August 18, 2024

Holy smoke, that's what I missed. Thanx. Working nicely right now.

from businesscentral.lintercop.

lvanvugt avatar lvanvugt commented on August 18, 2024

But the cyclomatic complexity is not done right IMHO.

Example 1

image
Shouldn't this be 1? No decisions, so basic 1.

Example 2

image
Shouldn't this be 4? Basic 1 plus 3 decisions.

from businesscentral.lintercop.

lvanvugt avatar lvanvugt commented on August 18, 2024

v0,15 + 1 = v1.15? Or v0.16? 😅

from businesscentral.lintercop.

StefanMaron avatar StefanMaron commented on August 18, 2024

What would be default thresholds to raise a warning instead of an info message?

from businesscentral.lintercop.

lvanvugt avatar lvanvugt commented on August 18, 2024

I reckon you do make it configurable, but you need a value to start with, right?

  • Cyclomatic complexity: between 6 and 10
  • Maintainability index: 20

from businesscentral.lintercop.

StefanMaron avatar StefanMaron commented on August 18, 2024

I will put it on the list! Could you please rephrase it into a new issue saying to document all the rules? Then it does not get lost ;)

from businesscentral.lintercop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.