-
Notifications
You must be signed in to change notification settings - Fork 50
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
Java LoC metric #694
Merged
calixteman
merged 19 commits into
mozilla:master
from
dburriss:dburriss/feature/issue-359/java-loc
Mar 23, 2022
Merged
Java LoC metric #694
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c98bc45
WIP of Java LoC metric
dburriss 22190ba
Enables 2 passing simple tests
dburriss d14a724
Adds more individual loc tests
dburriss b988696
Initial impl of JavaCode Getter trait
dburriss 3ce6450
Test cleanup
dburriss f28b458
Fix test
dburriss 2d11dbf
Fixes handling of for loops
dburriss 36cf32d
Adds while
dburriss 2108244
Remove println
dburriss ca1b35c
Ran fmt
dburriss 70a04ed
Reduce to handle only SLOC off by 1
dburriss aa42b7c
Adds ternary lloc to test
dburriss 7d4f9f1
Adds expression grammar lloc
dburriss 9c030c2
Removes expressions from count
dburriss c8112e1
Do not count expressions in for loop
dburriss c90d092
Removes debugging lines
dburriss 8bac42f
Fixes for the recent Stats changes
dburriss c765293
Defines space kinds
dburriss 0a7b404
Adds interface space
dburriss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My definition of space is: something which can have its own metrics.
So for example, you can have a class A with an inner class B each of them could be a space: this way we'll have some metrics for both of them:
And at the end in the final output you'll have the granularity the user wants.
So not having more spaces here means that we don't have any granularity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. I have taken a shot at it based on the other implementations and that explanation. Other than that not having
Program => SpaceKind::Unit
causes the line count to be off (javascript and typescript have this match too), I am uncertain how to actually test this in the context of LoC?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@calixteman I think this covers what can contain other code in Java. As I said in the above comment, I am uncertain how to test this in the context of LoC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to see space in actions you could just run
cargo run -p rust-code-analysis-cli -- -m -p foo.java
and have a look on the output, with foo.java:If you return unknown for any kind of space, you'll get some
unknown
in the output.Maybe the "off by 1" issue is related to:
https://github.com/mozilla/rust-code-analysis/blob/master/src/metrics/loc.rs#L40
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah cool! Makes complete sense. And yes that line of code was what led me to the fix of
Unit
forProgram
for the "off by 1" issue. It was in November last year when I started on this (and learning Rust) so the memories are a little hazy.Adding a lambda expression and a package to the java file didn't seem to add anything to the structure. Not sure if I should leave them in, conceptually it seems correct to me as is. The code on this comment is not showing as outdated but I do think the kind is working as you wanted. See image: