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

refactor: LPVSScanossDetectService refactoring and unit test fix #524

Merged
merged 4 commits into from
Jun 3, 2024

Conversation

tiokim
Copy link
Member

@tiokim tiokim commented May 31, 2024

Pull Request

Description

The checkLicenses has been refactored due to long method.
The unit tests, testWithNullHeadCommitSHA and testWithNullHeadCommitSHADB, have been fixed to read the existing test file.

Type of change

  • Code cleanup/refactoring

Testing

This PR was verified by the unit test.

Test Configuration:

  • Java: v17
  • LPVS Release: v1.x.x

Checklist:

  • My code follows the style guidelines of this project
  • My code meets the required code coverage for lines (90% and above)
  • My code meets the required code coverage for branches (80% and above)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@codecov-commenter
Copy link

codecov-commenter commented May 31, 2024

Codecov Report

Attention: Patch coverage is 93.75000% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 92.33%. Comparing base (03b112d) to head (3df2eab).

Files Patch % Lines
...service/scan/scanner/LPVSScanossDetectService.java 93.75% 1 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #524      +/-   ##
============================================
+ Coverage     92.28%   92.33%   +0.05%     
- Complexity      524      529       +5     
============================================
  Files            48       48              
  Lines          1736     1736              
  Branches        210      209       -1     
============================================
+ Hits           1602     1603       +1     
  Misses           69       69              
+ Partials         65       64       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@o-kopysov o-kopysov left a comment

Choose a reason for hiding this comment

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

Please check my comments. Thanks!

@@ -261,6 +181,96 @@ public List<LPVSFile> checkLicenses(LPVSQueue webhookConfig) {
return detectedFiles;
}

private Set<LPVSLicense> buildLicenseSet(ScanossJsonStructure object) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add Javadoc comments for all functions (including private).

Copy link
Member Author

Choose a reason for hiding this comment

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

Javadoc comments generated by GenAI are added. Please let me know if I have anything to revise!

+ ".json"));
}
Reader reader = getReader(webhookConfig);

// convert JSON file to map
Map<String, ArrayList<Object>> map =
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's possible to avoid usage of gson object here:
Map<String, ArrayList<Object>> map = new Gson().fromJson(reader, new TypeToken<Map<String, ArrayList<Object>>>() {}.getType());

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Thanks for your precise review!

}

private ScanossJsonStructure getScanossJsonStructure(Gson gson, String content, LPVSFile file) {
ScanossJsonStructure object = gson.fromJson(content, ScanossJsonStructure.class);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's possible to replace input parameter Gson gson and avoid usage of gson object like this:
ScanossJsonStructure object = new Gson().fromJson(content, ScanossJsonStructure.class);

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Thanks for your precise review!

Signed-off-by: Taewan Kim <t25.kim@samsung.com>
@o-kopysov o-kopysov added the enhancement New feature or request label Jun 3, 2024
@o-kopysov o-kopysov added this to the v1.5.2 milestone Jun 3, 2024
@o-kopysov o-kopysov changed the title LPVSScanossDetectService refactoring and unit test fix refactor: LPVSScanossDetectService refactoring and unit test fix Jun 3, 2024
Copy link
Collaborator

@o-kopysov o-kopysov left a comment

Choose a reason for hiding this comment

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

Thank you for the code refactoring!

@o-kopysov o-kopysov merged commit bbb8dfb into Samsung:main Jun 3, 2024
8 checks passed
@tiokim tiokim deleted the refactor_detectservice branch June 3, 2024 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants