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

feat: Add scanning of local files and folders (single scan) #558

Merged
merged 9 commits into from
Aug 7, 2024

Conversation

o-kopysov
Copy link
Collaborator

Pull Request

Description

Current PR contains:

  • implementation of the new feature - scanning of local files and folders with the possibility to generate reports in the console or an HTML file
  • update and extension of unit tests
  • fixes for several bugs that were found during the creation of new unit tests and local tests of the new feature
  • update of the documentation

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code cleanup/refactoring
  • Documentation update
  • This change requires a documentation update
  • CI system update
  • Test Coverage update

Testing

Unit tests and local functional tests.

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

Signed-off-by: Oleg Kopysov <o.kopysov@samsung.com>
@o-kopysov o-kopysov added documentation Improvements or additions to documentation new feature labels Jul 31, 2024
@o-kopysov o-kopysov added this to the v1.5.3 milestone Jul 31, 2024
@o-kopysov o-kopysov self-assigned this Jul 31, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jul 31, 2024

Codecov Report

Attention: Patch coverage is 93.80531% with 7 lines in your changes missing coverage. Please review.

Project coverage is 93.08%. Comparing base (420cc39) to head (dc1381e).

Files Patch % Lines
src/main/java/com/lpvs/util/LPVSFileUtil.java 82.60% 0 Missing and 4 partials ⚠️
...va/com/lpvs/service/LPVSQueueProcessorService.java 0.00% 0 Missing and 1 partial ⚠️
.../java/com/lpvs/service/scan/LPVSDetectService.java 98.43% 0 Missing and 1 partial ⚠️
src/main/java/com/lpvs/util/LPVSPayloadUtil.java 95.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #558      +/-   ##
============================================
+ Coverage     92.64%   93.08%   +0.44%     
- Complexity      530      545      +15     
============================================
  Files            48       48              
  Lines          1753     1822      +69     
  Branches        208      221      +13     
============================================
+ Hits           1624     1696      +72     
+ Misses           64       59       -5     
- Partials         65       67       +2     

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

tdrozdovsky
tdrozdovsky previously approved these changes Jul 31, 2024
Signed-off-by: Oleg Kopysov <o.kopysov@samsung.com>
t-naumenko
t-naumenko previously approved these changes Aug 1, 2024
Copy link
Collaborator

@t-naumenko t-naumenko left a comment

Choose a reason for hiding this comment

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

LGTM

m-rudyk
m-rudyk previously approved these changes Aug 2, 2024
Copy link
Collaborator

@m-rudyk m-rudyk left a comment

Choose a reason for hiding this comment

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

Approved

@o-kopysov
Copy link
Collaborator Author

@tiokim Please take a look at this PR. I would be grateful for your review and feedback.

tiokim
tiokim previously approved these changes Aug 5, 2024
Copy link
Member

@tiokim tiokim left a comment

Choose a reason for hiding this comment

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

LGTM!

// Check for any pending elements in the LPVSQueue.
queueService.checkForQueue();

// Process LPVSQueue elements until the trigger is set.
while (trigger == null || trigger.isEmpty()) {
while ((trigger == null || trigger.isEmpty())
Copy link
Member

Choose a reason for hiding this comment

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

What about using isBlank instead of isEmpty?

List<LPVSLicenseService.Conflict<String, String>> detectedConflicts = null;

// Error case when both pull request scan and local files scan are set to true
if (trigger != null && !trigger.isEmpty() && localPath != null && !localPath.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

What about using isBlank instead of isEmpty?

Signed-off-by: Oleg Kopysov <o.kopysov@samsung.com>
@o-kopysov o-kopysov dismissed stale reviews from tiokim, m-rudyk, and t-naumenko via 3221d85 August 5, 2024 08:08
Signed-off-by: Oleg Kopysov <o.kopysov@samsung.com>
Signed-off-by: Oleg Kopysov <o.kopysov@samsung.com>
Signed-off-by: Oleg Kopysov <o.kopysov@samsung.com>
log.info("Single scan of pull request completed.");
} catch (Exception ex) {
log.error("Single scan of pull request finished with errors.");
log.error("Can't trigger single scan: " + ex.getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

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

"Single scan finished" and at the same time "Can't trigger single scan"
What about use something general: ""
log.error("Single scan of pull request failed with error: " + ex.getMessage());

} catch (Exception ex) {
log.error("Single scan finished with errors.");
log.error("Single scan of local file(s) finished with errors.");
log.error("Can't trigger single scan: " + ex.getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about:
log.error("Single scan of local file(s) failed with error: " + ex.getMessage());

t-naumenko
t-naumenko previously approved these changes Aug 6, 2024
Copy link
Collaborator

@t-naumenko t-naumenko left a comment

Choose a reason for hiding this comment

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

There are 2 small suggestions about error logs, but in general LGTM

// Check for any pending elements in the LPVSQueue.
queueService.checkForQueue();

// Process LPVSQueue elements until the trigger is set.
while (trigger == null || trigger.isEmpty()) {
while ((trigger == null || trigger.isBlank())
&& (localPath == null || localPath.isBlank())) {
Copy link
Collaborator

@t-naumenko t-naumenko Aug 6, 2024

Choose a reason for hiding this comment

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

localPath.isBlank() includes a case with null, right?
If so, there is no reason to check it for localPath and trigger:

 while (trigger.isBlank())
                && (localPath.isBlank())
                ...

List<LPVSLicenseService.Conflict<String, String>> detectedConflicts = null;

// Error case when both pull request scan and local files scan are set to true
if (trigger != null && !trigger.isBlank() && localPath != null && !localPath.isBlank()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As isBlank include check for a null, so it could be simplified to:
if (!trigger.isBlank() && !localPath.isBlank())

Signed-off-by: Oleg Kopysov <o.kopysov@samsung.com>
Signed-off-by: Oleg Kopysov <o.kopysov@samsung.com>
Copy link
Collaborator

@t-naumenko t-naumenko left a comment

Choose a reason for hiding this comment

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

Good improvement! Thank you!

@o-kopysov o-kopysov merged commit 57c5e2b into main Aug 7, 2024
10 checks passed
@o-kopysov o-kopysov deleted the local-files-scan branch August 7, 2024 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants