Skip to content

Refactor BannedElement#1506

Merged
abbiefarr-zz merged 4 commits intomasterfrom
refactor-banned-element
Mar 2, 2017
Merged

Refactor BannedElement#1506
abbiefarr-zz merged 4 commits intomasterfrom
refactor-banned-element

Conversation

@abbiefarr-zz
Copy link
Copy Markdown
Contributor

Creates subclasses of BannedElement that contain a marker ID and severity, to allow validators to add more than one type of marker to a resource during validation.

@elharo @meltsufin

@Test(expected = NullPointerException.class)
public void testBannedElementConstructor_nullLocation() {
new BannedElement("test", null, 0);
new BannedElement("test", "", 1, null, 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 would expect that "" would be flagged as an illegal marker

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.

Marker IDs are only used when searching the resource for markers for quick fixes. Should I add my own check? IResource.createMarker(marker ID) doesn't have any checks.

createMarker(resource, entry.getKey(), entry.getValue(),
markerId, IMarker.SEVERITY_ERROR);
BannedElement element = entry.getKey();
createMarker(resource, element, entry.getValue(),
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.

You don't need to pass the markerId and severity separately. createMarker can simply call the getter methods on element

@@ -42,9 +42,7 @@ protected void validate(IResource resource, byte[] bytes)
Map<BannedElement, Integer> bannedElementOffsetMap =
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.

separate issue, but I just realized that since we're using BannedElement as a key in a map, we should give it equals and hashCode methods: #1507

int elementOffset, String markerId, int severity) throws CoreException {
IMarker marker = resource.createMarker(markerId);
marker.setAttribute(IMarker.SEVERITY, severity);
static void createMarker(IResource resource, BannedElement element, int elementOffset)
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.

Do we need to pass elementOffset here? Is it different than

element.getStart().getLineNumber()?

Copy link
Copy Markdown
Contributor Author

@abbiefarr-zz abbiefarr-zz Mar 1, 2017

Choose a reason for hiding this comment

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

Yes, elementOffset is the character offset

@codecov-io
Copy link
Copy Markdown

codecov-io commented Mar 1, 2017

Codecov Report

Merging #1506 into master will increase coverage by 0.1%.
The diff coverage is 100%.

@@             Coverage Diff             @@
##             master    #1506     +/-   ##
===========================================
+ Coverage     70.09%   70.19%   +0.1%     
- Complexity     1263     1272      +9     
===========================================
  Files           222      225      +3     
  Lines          8860     8887     +27     
  Branches        751      755      +4     
===========================================
+ Hits           6210     6238     +28     
+ Misses         2334     2332      -2     
- Partials        316      317      +1
Impacted Files Coverage Δ Complexity Δ
...ls/eclipse/appengine/validation/WebXmlScanner.java 90% <100%> (ø) 5 <0> (ø)
...lipse/appengine/validation/JavaServletElement.java 100% <100%> (ø) 1 <1> (?)
...eclipse/appengine/validation/BlacklistScanner.java 100% <100%> (ø) 3 <0> (ø)
...lipse/appengine/validation/MavenPluginElement.java 100% <100%> (ø) 1 <1> (?)
...appengine/validation/AppEngineWebXmlValidator.java 100% <100%> (ø) 3 <0> (ø)
...ls/eclipse/appengine/validation/BannedElement.java 94.73% <100%> (+2.42%) 7 <4> (+2)
.../eclipse/appengine/validation/PomXmlValidator.java 90% <100%> (-1.67%) 3 <0> (ø)
...pse/appengine/validation/AbstractXmlValidator.java 89.28% <100%> (ø) 6 <1> (ø)
.../eclipse/appengine/validation/WebXmlValidator.java 90% <100%> (-1.67%) 3 <0> (ø)
...ppengine/validation/AppEngineBlacklistElement.java 100% <100%> (ø) 1 <1> (?)
... and 8 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 4aa7628...7a55c4d. Read the comment docs.

@abbiefarr-zz abbiefarr-zz merged commit 5ae9f20 into master Mar 2, 2017
@abbiefarr-zz abbiefarr-zz deleted the refactor-banned-element branch March 2, 2017 14:04
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