Skip to content

Simplify library code#1587

Merged
chanseokoh merged 6 commits intomasterfrom
simplify-library-code
Mar 14, 2017
Merged

Simplify library code#1587
chanseokoh merged 6 commits intomasterfrom
simplify-library-code

Conversation

@chanseokoh
Copy link
Copy Markdown
Contributor

I was looking at the code in .libraries and thought I could improve readability a bit, mainly by using List in place of primitive Java arrays.

@akerekes what do you think?

@codecov-io
Copy link
Copy Markdown

codecov-io commented Mar 13, 2017

Codecov Report

Merging #1587 into master will increase coverage by 0.09%.
The diff coverage is 61.22%.

@@             Coverage Diff              @@
##             master    #1587      +/-   ##
============================================
+ Coverage     71.03%   71.12%   +0.09%     
- Complexity     1337     1340       +3     
============================================
  Files           238      238              
  Lines          9083     9074       -9     
  Branches        781      780       -1     
============================================
+ Hits           6452     6454       +2     
+ Misses         2303     2293      -10     
+ Partials        328      327       -1
Impacted Files Coverage Δ Complexity Δ
...e/libraries/persistence/SerializableAttribute.java 100% <ø> (ø) 2 <0> (ø)
...istence/SerializableLibraryClasspathContainer.java 100% <100%> (ø) 4 <4> (ø)
...ibraries/LibraryClasspathContainerInitializer.java 100% <100%> (ø) 11 <0> (ø)
...ipse/appengine/libraries/model/LibraryFactory.java 72.83% <100%> (+1.23%) 16 <2> (ø)
...libraries/persistence/SerializableAccessRules.java 83.33% <100%> (ø) 2 <0> (ø)
...appengine/libraries/LibraryClasspathContainer.java 92.85% <100%> (ø) 6 <1> (ø)
...raries/persistence/SerializableClasspathEntry.java 79.62% <12.5%> (ø) 16 <0> (ø)
...eclipse/appengine/libraries/SourceAttacherJob.java 64.7% <47.36%> (+14.7%) 5 <2> (+2)
...tory/LibraryClasspathContainerResolverService.java 83.91% <81.81%> (-0.92%) 33 <4> (-1)
...pse/appengine/validation/AbstractXmlValidator.java 90.32% <0%> (-6.46%) 7% <0%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e343af...e0f6c6f. Read the comment docs.

@Override
public IClasspathEntry[] getClasspathEntries() {
return classpathEntries;
return classpathEntries.toArray(new IClasspathEntry[0]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is why the arrays are used. A lot of the Eclipse API around this uses lists.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we need extra conversion here, but overall, looks like using a List is a win.

serializer.saveContainer(javaProject, newContainer);
return Status.OK_STATUS;

} catch (Exception ex) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks like something we should fix if possible. (not in this PR) Why are we catching java.lang.Exception here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sourceArtifactPathProvider is a Callable and this call() declares Exception to be thrown. We can either replace it with a com.google.common.base.Supplier, swallow any exception that happens inside and return a nullor create an interface similar toCallableand declareCoreException` to be thrown.

@@ -54,37 +56,36 @@ protected IStatus run(IProgressMonitor monitor) {
try {
IClasspathContainer container = JavaCore.getClasspathContainer(containerPath, javaProject);
if (container instanceof LibraryClasspathContainer) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't the condition be negated? If so, and tests are still passing can you add one that fails on this before fixing it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Wow, nice catch!

@chanseokoh chanseokoh merged commit 3c53443 into master Mar 14, 2017
@chanseokoh chanseokoh deleted the simplify-library-code branch March 14, 2017 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants