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

Manually parse the Ant configUrl field into a URL #4463

Merged
merged 1 commit into from Jun 25, 2017
Merged

Manually parse the Ant configUrl field into a URL #4463

merged 1 commit into from Jun 25, 2017

Conversation

dimo414
Copy link
Contributor

@dimo414 dimo414 commented Jun 16, 2017

so that invalid URLs can be treated as resource paths. Fixes #4449.

@rnveach
Copy link
Member

rnveach commented Jun 17, 2017

@dimo414 CI must pass. Code style and code coverage are failing.
Please keep number of commits at 1.

@dimo414
Copy link
Contributor Author

dimo414 commented Jun 20, 2017

Sorry, I mistakenly only ran mvn test before. mvn verify now passes locally.

@dimo414
Copy link
Contributor Author

dimo414 commented Jun 20, 2017

Hmm, seems like AppVeyor still isn't happy, though I'm not sure why. I can't replicate the failure locally. Any pointers?

@rnveach
Copy link
Member

rnveach commented Jun 20, 2017

appveyor is a windows machine. It is failing on code coverage. Travis has same failure, so most likely you are not getting coverage of your new catch for MalformedURLException .

@dimo414
Copy link
Contributor Author

dimo414 commented Jun 20, 2017

Odd, I added testConfigurationByResource() to detect that case, and verified locally that it enters the catch block. I'll try to verify on a Windows machine later.

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

change is required:

setConfigLocation(url.toExternalForm());
public void setConfigUrl(String url) {
try {
setConfigLocation(new URL(url).toExternalForm());
Copy link
Member

Choose a reason for hiding this comment

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

no need to do instantiation of URL here final URI uri = CommonUtils.getUriByFilename(config); , string could stored as is , to be processed at
https://github.com/checkstyle/checkstyle/blob/master/src/main/java/com/puppycrawl/tools/checkstyle/ConfigurationLoader.java#L179

conversion to URL/URI - https://github.com/checkstyle/checkstyle/blob/master/src/main/java/com/puppycrawl/tools/checkstyle/utils/CommonUtils.java#L372

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not clear what you're suggesting - do you want me to use CommonUtils.getUriByFilename() instead, or are you saying setConfigUrl() should simply be:

public void setConfigUrl(String url) {
    setConfigLocation(url);
}

?

I think that the latter would be a breaking change for callers that rely on .toExternalForm() being called, but if that doesn't concern you I can change it to that.

Copy link
Member

Choose a reason for hiding this comment

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

we are decided to go further with breaking compatibility changes, please read #4449 (comment)

@dimo414
Copy link
Contributor Author

dimo414 commented Jun 21, 2017

I've not been able to replicate this on my Windows 10 machine - I run into a number of other seemingly unrelated failures (e.g. in AstRegressionTest).

@romani
Copy link
Member

romani commented Jun 21, 2017

@dimo414 , please share some logs from your local windows to let us help you.

Attention: please read #4449 (comment)

@dimo414
Copy link
Contributor Author

dimo414 commented Jun 21, 2017

Ok, I've swapped everything to setConfig(String) as suggested in the bug thread.

Copy link
Member

@rnveach rnveach left a comment

Choose a reason for hiding this comment

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

@romani I don't see anything else.

}
configLocation = location;
configLocation = file;
Copy link
Member

Choose a reason for hiding this comment

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

Please rename configLocation to config so it is seen as a bean.
We are already starting to do this with checks, so reflection utilities will recognize them and tie them together.

Copy link
Member

Choose a reason for hiding this comment

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

please make method argument to be public void setConfig(String config) {
to make it similar to
public static Configuration loadConfiguration(String config, .... as here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done and done - I'd used setConfig(String file) since that's what you suggested in #4449 (comment), but this certainly makes more sense.

@romani
Copy link
Member

romani commented Jun 22, 2017

Travis failures "The forked VM terminated without properly saying goodbye." could be ignored, known instability problem. All other problems need to be resolved.

@romani
Copy link
Member

romani commented Jun 22, 2017

Please also rebase on latest master, we did travis fix, it should pass.

@codecov-io
Copy link

codecov-io commented Jun 24, 2017

Codecov Report

Merging #4463 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #4463   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files         285     285           
  Lines       15323   15317    -6     
  Branches     3489    3489           
======================================
- Hits        15323   15317    -6
Impacted Files Coverage Δ
...ycrawl/tools/checkstyle/ant/CheckstyleAntTask.java 100% <100%> (ø) ⬆️

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 ecb07ad...dbf1f92. Read the comment docs.

@rnveach
Copy link
Member

rnveach commented Jun 24, 2017

@dimo414 you have test failures and checkstyle errors.

@dimo414
Copy link
Contributor Author

dimo414 commented Jun 24, 2017

Sorry, that was sloppy - I can't get Checkstyle to build on my Windows box so I just made the requested changes. I'll try to fix them.

@romani
Copy link
Member

romani commented Jun 24, 2017

I can't get Checkstyle to build on my Windows box

did you share with us your build log with problem ? We have CI for Windows build and we have some team members on Windows, all problems resolved a while ago.

@dimo414
Copy link
Contributor Author

dimo414 commented Jun 25, 2017

Ok, fixed the test failure, but the requested changes (to name the field and the parameter both config) conflict, according to CheckStyle:

[checkstyle] [ERROR] /tmp/github/checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask.java:394:33: 'config' hides a field. [HiddenField]

How would you like me to proceed? Rename one or the other? Or is there a way to suppress this?

@romani
Copy link
Member

romani commented Jun 25, 2017

How would you like me to proceed?

unfortunate case, but public names are above in priority.
Please rename local variable config to configuration.

… arbitrary strings, to be consistent with other config logic
@dimo414
Copy link
Contributor Author

dimo414 commented Jun 25, 2017

Ok, mvn verify passes, hopefully CI likes it.

@romani romani merged commit 61f2ef2 into checkstyle:master Jun 25, 2017
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.

None yet

4 participants