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: Initial version of HTML report generation for single scan #573

Closed
wants to merge 2 commits into from

Conversation

o-kopysov
Copy link
Collaborator

@o-kopysov o-kopysov commented Aug 14, 2024

Pull Request

Description

The current PR contains improvements in the HTML reports generated by a single scan (scan of PR or local file(s)).

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

java -jar -Dspring.profiles.active=singlescan target/lpvs-*.jar --github.pull.request=https://github.com/o-kopysov/LPVS/pull/2 --build.html.report=report.html
java -jar -Dspring.profiles.active=singlescan target/lpvs-*.jar --local.path=test --build.html.report=test/report.html

image

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 the enhancement New feature or request label Aug 14, 2024
@o-kopysov o-kopysov added this to the v1.6.0 milestone Aug 14, 2024
@o-kopysov o-kopysov self-assigned this Aug 14, 2024
@codecov-commenter
Copy link

codecov-commenter commented Aug 14, 2024

Codecov Report

Attention: Patch coverage is 94.53782% with 13 lines in your changes missing coverage. Please review.

Project coverage is 93.04%. Comparing base (8b5fb97) to head (97921cf).

Files Patch % Lines
...java/com/lpvs/entity/report/LPVSReportBuilder.java 94.64% 5 Missing and 7 partials ⚠️
src/main/java/com/lpvs/util/LPVSCommentUtil.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #573       +/-   ##
===========================================
+ Coverage        0   93.04%   +93.04%     
- Complexity      0      575      +575     
===========================================
  Files           0       49       +49     
  Lines           0     1999     +1999     
  Branches        0      231      +231     
===========================================
+ Hits            0     1860     +1860     
- Misses          0       66       +66     
- Partials        0       73       +73     

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

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

@tiokim do you have any comments regarding PR?

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.

Great job!

@@ -38,6 +38,11 @@
</properties>

<dependencies>
<dependency>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's check solution with 'ConfigurableApplicationContext'

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.

Please check comments and suggestion. Some part need to be simplified.

private String scannerType;

private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private Map<String, GroupInfo<Map<String, GroupInfo<Map<String, GroupInfo<List<LPVSFile>>>>>>>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd suggest to create custom classes for this structure:
'ComponentInfo'
'AccessInfo'
'LicenseInfo'

Comment on lines +150 to +208
if (detectedLicenseInfo == null && scanResults != null && !scanResults.isEmpty()) {
List<LPVSFile> filesScanResults = getLpvsFilesFromScanResults(scanResults);

detectedLicenseInfo =
filesScanResults.stream()
.collect(
Collectors.groupingBy(
LPVSFile ->
LPVSFile.getLicenses().stream()
.findFirst()
.get()
.getAccess(),
Collectors.collectingAndThen(
Collectors.groupingBy(
LPVSFile ->
LPVSFile.getLicenses().stream()
.findFirst()
.get()
.getSpdxId(),
Collectors.collectingAndThen(
Collectors.groupingBy(
LPVSFile ->
LPVSFile
.getComponentVendor()
+ " / "
+ LPVSFile
.getComponentName()
+ ":::"
+ LPVSFile
.getComponentUrl(),
Collectors
.collectingAndThen(
Collectors
.toList(),
elements ->
new GroupInfo<>(
elements
.size(),
elements))),
groupedByComponent ->
new GroupInfo<>(
groupedByComponent
.values()
.stream()
.mapToLong(
GroupInfo
::getCount)
.sum(),
groupedByComponent))),
groupedByLicense ->
new GroupInfo<>(
groupedByLicense
.values()
.stream()
.mapToLong(
GroupInfo
::getCount)
.sum(),
groupedByLicense))));
Copy link
Collaborator

Choose a reason for hiding this comment

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

to much for single instruction. Split required here.

How about:

Map<String, GroupInfo<?>> detectedLicenseInfo = filesScanResults.stream()
    .collect(Collectors.groupingBy(
        this::getFirstLicenseAccess,
        Collectors.collectingAndThen(
            Collectors.groupingBy(
                this::getFirstLicenseSpdxId,
                Collectors.collectingAndThen(
                    Collectors.groupingBy(
                        this::getComponentKey,
                        Collectors.collectingAndThen(
                            Collectors.toList(),
                            this::createGroupInfo
                        )
                    ),
                    this::summarizeGroupInfo
                )
            ),
            this::summarizeGroupInfo
        )
    ));
and after that implement corresponding methods?

together with created classes above it will be much easier to maintain.

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.

Sorry for the late review! Overall it looks great!


@BeforeEach
public void setUp() throws Exception {
lic1 =
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice if the variable name is better named around the functionality like licMIT instead of simple number.

@o-kopysov o-kopysov marked this pull request as draft August 20, 2024 13:09
@o-kopysov o-kopysov closed this Aug 23, 2024
@o-kopysov o-kopysov deleted the html-report branch August 23, 2024 09:03
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.

6 participants