Skip to content

Comments

Sort all collections when serializing#35

Merged
goneall merged 7 commits intomasterfrom
issue34
Jan 29, 2023
Merged

Sort all collections when serializing#35
goneall merged 7 commits intomasterfrom
issue34

Conversation

@goneall
Copy link
Member

@goneall goneall commented Jan 28, 2023

Fixes #34

Also includes some minor performance improvements
Sorting does degrade the performance by about 40% on the optimized code. However, it is still reasonably fast at >28,000 lines per second on my machine.

Signed-off-by: Gary O'Neall <[email protected]>
Fixes #34
Also includes some minor performance improvements
Sorting does degrate the performance by about 40% on the optimized
code.  However, it is still reasonably fast at >28,000 lines per
second on my machine
Signed-off-by: Gary O'Neall <[email protected]>
}
// Creators
Collection<String> creators = doc.getCreationInfo().getCreators();
List<String> creators = new ArrayList<>(doc.getCreationInfo().getCreators());
Copy link

Choose a reason for hiding this comment

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

15% of developers fix this issue

NULL_DEREFERENCE: object returned by doc.getCreationInfo() could be null and is dereferenced at line 183.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

// first print out any described files or snippets
final List<SpdxElement> alreadyPrinted = new ArrayList<>();
Collection<SpdxElement> items = doc.getDocumentDescribes();
final Set<SpdxElement> alreadyPrinted = new HashSet<>();
Copy link

Choose a reason for hiding this comment

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

10% of developers fix this issue

💬 2 similar findings have been found in this PR


UnnecessaryFinal: Since Java 8, it's been unnecessary to make local variables and parameters final for use in lambdas or anonymous classes. Marking them as final is weakly discouraged, as it adds a fair amount of noise for minimal benefit.


Suggested change
final Set<SpdxElement> alreadyPrinted = new HashSet<>();
Set<SpdxElement> alreadyPrinted = new HashSet<>();

🔎 Expand here to view all instances of this finding
File Path Line Number
src/main/java/org/spdx/tag/CommonCode.java 221
src/main/java/org/spdx/tag/CommonCode.java 227

Visit the Lift Web Console to find more details in your report.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@sonatype-lift
Copy link

sonatype-lift bot commented Jan 29, 2023

🛠 Lift Auto-fix

Some of the Lift findings in this PR can be automatically fixed. You can download and apply these changes in your local project directory of your branch to review the suggestions before committing.1

# Download the patch
curl https://lift.sonatype.com/api/patch/github.com/spdx/spdx-java-tagvalue-store/35.diff -o lift-autofixes.diff

# Apply the patch with git
git apply lift-autofixes.diff

# Review the changes
git diff

Want it all in a single command? Open a terminal in your project's directory and copy and paste the following command:

curl https://lift.sonatype.com/api/patch/github.com/spdx/spdx-java-tagvalue-store/35.diff | git apply

Once you're satisfied commit and push your changes in your project.

Footnotes

  1. You can preview the patch by opening the patch URL in the browser.

@goneall goneall merged commit b634250 into master Jan 29, 2023
@goneall goneall deleted the issue34 branch January 29, 2023 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sort output on serialization

1 participant