Comments (28)
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.
Do you have "al.enableCodeAnalysis": true
in settings?
from businesscentral.lintercop.
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.
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:
- Always show the values of maintainability Index and cyclomatic complexity on every procedure and trigger as an
Info
message - 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.
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.
from businesscentral.lintercop.
from businesscentral.lintercop.
They should show up between other warnings or if you have error lens, right behind the function in code
from businesscentral.lintercop.
Glad to hear it works :)
I will update the readme later to make the install a bit clearer
from businesscentral.lintercop.
I did not add the plus 1. 😅 but that will be an easy one
from businesscentral.lintercop.
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.
BTW2: the same applies to Maintainability Index.
from businesscentral.lintercop.
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.
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.
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.
When will it be available?
from businesscentral.lintercop.
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.
from businesscentral.lintercop.
How to enable the info message?
from businesscentral.lintercop.
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.
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.
Doesn't show at all. Any way to check things in the background?
from businesscentral.lintercop.
Holy smoke, that's what I missed. Thanx. Working nicely right now.
from businesscentral.lintercop.
But the cyclomatic complexity is not done right IMHO.
Example 1
Shouldn't this be 1? No decisions, so basic 1.
Example 2
Shouldn't this be 4? Basic 1 plus 3 decisions.
from businesscentral.lintercop.
v0,15 + 1 = v1.15? Or v0.16? 😅
from businesscentral.lintercop.
What would be default thresholds to raise a warning instead of an info message?
from businesscentral.lintercop.
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.
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)
- LC0035 - Table Extension Fields HOT 1
- LC0054 'BusinessCentral.LinterCop.Design.Rule0054FollowInterfaceObjectNameGuide' threw an exception of type 'System.NullReferenceException' HOT 3
- LC0064 - False positive on page controls not using Rec. HOT 1
- AD0001 in specific app.json HOT 8
- LC0033 HOT 3
- LC0063 - false positive for global variable HOT 2
- Howto run test in VS Code? HOT 9
- LC0035 - False Positive FlowField HOT 6
- LC0027: Handle on Variant as Table, with Supported Page
- LC0004 - False Positive for Page with property SourceTableTemporary = true; HOT 1
- Artifacts `.current.dll` and `.next.dll` will become obsolete in the future
- LC0067 - false positve for Journal Template Tables HOT 3
- LC0033 false positives HOT 2
- Rule0005VariableCasingShouldNotDifferFromDeclaration NullReferenceException
- LC0068 Rule0068CheckObjectPermission - InvalidCastException [AL preview - v14.0.1070882] HOT 1
- LC0068 - Triggering on TableExt/PageExt HOT 1
- LC0068 - False Positive - Record Identical to Page Record HOT 1
- LC0005: Xmlport instead of XmlPort HOT 4
- LC0068 does not handle fully qualified table names HOT 1
- LC0031 - ReadIsolation - Description is ambiguous
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from businesscentral.lintercop.