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

Add category and type to code duplication issues #939

Merged

Conversation

emouty
Copy link
Contributor

@emouty emouty commented Aug 9, 2023

Testing done

I have noticed that there were no category nor type on cpd issues, which impact their integration with other tools.
In the category tab on Jenkins, it render a blank line which make them non clickable.

In the type tab, they are rendered with a - and gathered with all the other categorized issues.

And in the issue tab they are not easily identifiable without category nor type

So I proposed to set for all cpd issues a category CPD and for type CodeDuplication

Submitter checklist

@emouty emouty force-pushed the add_type_and_category_to_cpd_issues branch 3 times, most recently from f593b0d to 423d363 Compare August 9, 2023 10:49
@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Merging #939 (f90c316) into master (a137c72) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##             master     #939   +/-   ##
=========================================
  Coverage     92.91%   92.92%           
  Complexity     2338     2338           
=========================================
  Files           345      345           
  Lines          6495     6499    +4     
  Branches        672      672           
=========================================
+ Hits           6035     6039    +4     
  Misses          262      262           
  Partials        198      198           
Files Changed Coverage Δ
.../hafner/analysis/parser/dry/AbstractDryParser.java 90.90% <100.00%> (+0.43%) ⬆️
...u/hm/hafner/analysis/parser/dry/cpd/CpdParser.java 93.33% <100.00%> (+0.22%) ⬆️
...analysis/parser/dry/dupfinder/DupFinderParser.java 95.34% <100.00%> (+0.11%) ⬆️
...afner/analysis/parser/dry/simian/SimianParser.java 93.10% <100.00%> (+0.24%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@uhafner
Copy link
Member

uhafner commented Aug 10, 2023

I wonder if we should better implement that in the warnings plug-in and convert all empty types and categories by default to a „-„? The dash is used for other empty elements as well.

On the other hand, a category for duplications in the analysis model would not hurt. But a category and type seems to be redundant for me. What do you think?

@uhafner uhafner added the enhancement Enhancement of existing functionality label Aug 10, 2023
@emouty
Copy link
Contributor Author

emouty commented Aug 11, 2023

Yes, it could be nice to have a dash for empty categories on warning ng. that could be useful also for other parsers.

I know it seems redundant to have a category and a type for cpd duplication on the issue tab, but for the type tab and the category tab, that would be helpful to distinguish them from other uncategorized issues or not typed issues.

If we need to choose, I think setting the category would be better as for now there is no default category for uncategorized issues.

Copy link
Member

@uhafner uhafner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then let us add these values.

@@ -64,6 +64,8 @@ protected Report convertDuplicationsToIssues(final List<Duplication> duplication
.setLineStart(file.getLine())
.setLineEnd(file.getLine() + duplication.getLines() - 1)
.setFileName(file.getPath())
.setCategory("CPD")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the category to

issueBuilder.setMessage("Found duplicated code.");

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to set the category to „Code Duplication“.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not yet addressed. Can't this be moved to the parent class?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And „Code Duplication“ reads better than CamelCase.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad I missed that one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good now.
I replaced buildAndClean() by build() in SimianParser and DupFinderParser otherwise from the second iteration in the duplication.getBlocks() loop you would loose the consolidated fields (message and category) from the AbstractDryParser.
Didn't needed to do it in CPDParser as it already used build().

@@ -64,6 +64,8 @@ protected Report convertDuplicationsToIssues(final List<Duplication> duplication
.setLineStart(file.getLine())
.setLineEnd(file.getLine() + duplication.getLines() - 1)
.setFileName(file.getPath())
.setCategory("CPD")
.setType("CodeDuplication")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And use „CPD“ as type here. It would be nice to set the type for the other two parsers as well.

@emouty emouty force-pushed the add_type_and_category_to_cpd_issues branch from 423d363 to df7d4b4 Compare August 14, 2023 08:01
@emouty emouty changed the title Add category and type to cpd issues Add category and type to code duplication issues Aug 14, 2023
@emouty emouty requested a review from uhafner August 14, 2023 08:01
@emouty emouty force-pushed the add_type_and_category_to_cpd_issues branch from df7d4b4 to f90c316 Compare August 14, 2023 11:56
Copy link
Member

@uhafner uhafner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@uhafner uhafner merged commit 85dac07 into jenkinsci:master Sep 4, 2023
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants