Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cognitive metric when there are no functions #387

Merged
merged 2 commits into from
Jan 25, 2021

Conversation

Luni-4
Copy link
Collaborator

@Luni-4 Luni-4 commented Dec 3, 2020

No description provided.

@codecov-io
Copy link

codecov-io commented Dec 4, 2020

Codecov Report

Merging #387 (946bec0) into master (2fff14d) will decrease coverage by 0.20%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #387      +/-   ##
==========================================
- Coverage   23.29%   23.08%   -0.21%     
==========================================
  Files          45       45              
  Lines        5491     5870     +379     
  Branches      805      826      +21     
==========================================
+ Hits         1279     1355      +76     
- Misses       3689     3988     +299     
- Partials      523      527       +4     
Impacted Files Coverage Δ
src/macros.rs 28.12% <ø> (-23.23%) ⬇️
src/metrics/cognitive.rs 64.31% <75.00%> (+5.30%) ⬆️
src/c_macro.rs 66.15% <0.00%> (-14.98%) ⬇️
src/metrics/mi.rs 46.00% <0.00%> (-14.61%) ⬇️
src/metrics/halstead.rs 32.25% <0.00%> (-12.91%) ⬇️
src/metrics/loc.rs 44.15% <0.00%> (-9.82%) ⬇️
src/spaces.rs 56.28% <0.00%> (-5.56%) ⬇️
src/metrics/nom.rs 45.88% <0.00%> (-5.44%) ⬇️
src/languages/language_cpp.rs 0.00% <0.00%> (ø)
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2fff14d...946bec0. Read the comment docs.

@Luni-4
Copy link
Collaborator Author

Luni-4 commented Dec 15, 2020

@marco-c

I propose to use the 0 approach instead of the null one when there are no functions. Since we are using a counting approach for cognitive (and for all the other metrics), if something doesn't exist, the count remains set to 0.

Perhaps we could add a comment to the code in order to explain our approach. What do you think?

@marco-c
Copy link
Collaborator

marco-c commented Dec 23, 2020

I'm thinking we should use null, so users can differentiate an actual 0 cognitive complexity from a not-existent cognitive complexity.
Users who want to consider null as 0 can do so, and users who want to differentiate can do that too.
Instead, if we save 0 for everything, only the first kind of usage would be possible.

@Luni-4
Copy link
Collaborator Author

Luni-4 commented Dec 24, 2020

Seems good to me, I'm going to change the metrics in that way then

@Luni-4
Copy link
Collaborator Author

Luni-4 commented Jan 11, 2021

@marco-c

Now it is ready

@marco-c marco-c merged commit 09fdaab into mozilla:master Jan 25, 2021
@Luni-4 Luni-4 deleted the fix-cognitive branch January 25, 2021 10:03
spacedragon pushed a commit to spacedragon/rust-code-analysis that referenced this pull request Feb 2, 2021
* Add a way to compare NAN values in tests

* Set cognitive average value to NAN when no functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants