Repository navigation
Use Policeman Tools - #1213
Use Policeman Tools#1213boldtrn wants to merge 5 commits into
Conversation
|
Cool & thanks!
Hmmh, as the example and several other issues are no user input strings, this would introduce a bit ugliness without a benefit, especially for string comparison. Is there a possibility to skip or ignore them? |
This really depends. For example in this blog you can find a couple of samples that show String comparision for e.g., the turkish language. This prints: bıke which is not equal to bike (compare the i). This means if for example we read "BIKE" from somewhere, does not need to be user input, can be defined somewhere in our code, and would want to match it with .toLowerCase to bike, this will fail. Ok, this example might be far fetched, but I see a benefit of adding a locale. In the end, we might not introduce this issue, but maybe someone that uses GraphHopper as a library and passes a String to a method. |
|
Thanks - this is interesting and convincing example, still the resulting code would be ugly ;) Maybe we introduce toLowerCase(String) as static helper method so we can write |
|
Locale.ROOT obviously ;) |
|
Ok, so I fixed most issues that the Policeman Tools reported, I left a couple of issues unaddressed and added the whole class to the ignore file. WDYT? |
| com/graphhopper/util/Helper7.class | ||
| </exclude> | ||
| <exclude> | ||
| com/graphhopper/storage/UnsafeDataAccess.class |
There was a problem hiding this comment.
Policeman Tools does not like usage of unsafe packages :)
| </exclude> | ||
| <!-- Has a couple of issues with the FileWriter --> | ||
| <exclude> | ||
| com/graphhopper/tools/Measurement.class |
There was a problem hiding this comment.
Shouldn't be very important to fix the measurement anyway?
| </exclude> | ||
| <!-- orbidden class/interface use: java.io.FileReader [Uses default charset] --> | ||
| <exclude> | ||
| com/graphhopper/spatialrules/SpatialRuleLookupHelper.class |
There was a problem hiding this comment.
These two use the FileReader. From the Javadoc:
The constructors of this class assume that the default character encoding and the default byte-buffer size are appropriate. To specify these values yourself, construct an InputStreamReader on a FileInputStream.
I would fix this, if we decide to use PolicemanTools :).
There was a problem hiding this comment.
Ok, I fixed the FileReader issue as well.
|
How about |
|
@devemux86 do you mean createFormatter should use Locale.ROOT instead of Locale.UK? |
|
It uses UTC time zone, so appears to be special case? |
|
Not sure what you mean ... can you elaborate :) ? This wasn't touched in this PR and is very important to avoid a local e.g. DE setting being propagated to consuming clients located e.g. in US (GPX export etc) |
|
Because it wasn't changed, I wondered the case. |
|
Yes, GPX should not be filled with German formatting and should be UTC. |
Yes, and it is. Here is one sample line from a generated GPX, using GH and this branch.
This is correctly formatted and also the correct UTC time. |
Fix one issue Fixed most PolicemanTools issues Android sample: Gradle 4, Android plugin 3, SDK 27 make size to use shape vs. edgeId configurable, improves graphhopper#1214 minor UI style fixes
…pper#1216 Introduce Instruction.getLength() that fixes the ViaPoint issue
476f45a to
e8c8b21
Compare
|
Ok, apparently I merged the master into this PR some time ago and forgot when I squashed. So this PR looks now broken as well. Again I can try to rebuild it in a new PR. Not sure if I use a wrong command or if there is a way to revert the squash. I tried with |
|
The new PR is located at #1236. I got it fixed with: as described here. |
|
BTW: you should be able to push into the same PR (no need to create a new) |
Yes I thought so, but I wasn't sure if this might make things worse, sorry about that. |
|
No problem. Better a new branch or PR instead of a wrong forced push, because they are really dangerous if applied in the wrong place :) |
These were exactly my thoughts as well |
As mentioned in #1210, it would be nice to use the policeman tools to avoid locale issues.
I just pasted the default configuration of the policeman tools. I changed it so it does only run on travis or by using
mvn forbiddenapis:check. It finds a lot of issues for the core so far.For example:
The fix that was proposed here, is to rewrite the above line to:
Should I go ahead and try to fix all the found issues by the policeman tools?
The full list of issues for the core is: