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

AndroidLintParser doesn't expose rule correctly #39

Closed
TWiStErRob opened this issue Aug 18, 2018 · 9 comments
Closed

AndroidLintParser doesn't expose rule correctly #39

TWiStErRob opened this issue Aug 18, 2018 · 9 comments

Comments

@TWiStErRob
Copy link
Contributor

https://github.com/tomasbjerre/violations-lib/blob/master/src/main/java/se/bjurr/violations/lib/parsers/AndroidLintParser.java

uses

String id = getAttribute(issueChunk, "id");
String rule = getAttribute(issueChunk, "category");
...
.setRule(rule)
.setMessage(id + ": " + summary + "\n" + message + "\n" + explanation)

notice that the category is used for rule, which is wrong. The rule should be the ID as that's what's failed, category is like "Accessibility" which category can have 10 different rules inside it.

What can we do?

@tomasbjerre
Copy link
Owner

Ok.

So .setRule(id).

Any suggestions on how to change .setMessage(id + ": " + summary + "\n" + message + "\n" + explanation) ? Or should the category not be included anywhere?

I never used AndroidLint myself so not really sure what is the best way of showing the findings.

@TWiStErRob
Copy link
Contributor Author

I dropped you a mail with an example output of Android Lint, that should help you understand this.

re

Any suggestions on how to change .setMessage(id + ": " + summary + "\n" + message + "\n" + explanation) ? Or should the category not be included anywhere?

I think your Violation model may be missing a category/group field, as PMD, Checkstyle, Lint, Detekt (the tools we use all have that). So I would say it's pretty common to have the rules/checks grouped by type.

@tomasbjerre
Copy link
Owner

I can see PMD has ruleSet. But what would be the category when it comes to Checkstyle, Lint and Detekt?

tomasbjerre added a commit that referenced this issue Aug 18, 2018
@TWiStErRob
Copy link
Contributor Author

Checkstyle: the groups on the left? http://checkstyle.sourceforge.net/checks.html
Hmm, it looks like it's only documentation it seems that the output doesn't support this (checkstyle/checkstyle#5166).
I could open a PR that does a best effort to reproduce these categories? (i.e. a hash from check name to category)

Detekt: see example output https://github.com/arturbosch/detekt/raw/master/img/detekt_in_action.png and configuration https://github.com/arturbosch/detekt/blob/master/detekt-cli/src/main/resources/default-detekt-config.yml
I think re Detekt the problem is that it's read through Checkstyle's output format which doesn't have this field.

tomasbjerre added a commit that referenced this issue Aug 18, 2018
@tomasbjerre
Copy link
Owner

Ok. I'm pushing the change you suggested in your comment on my diff now.

You can give it a shot with a PR.

Regarding Detekt I think so as well. It is not in the checkstyle format. If you want to add a Detekt parser, that is great =)

@TWiStErRob
Copy link
Contributor Author

Probably eventually, right now I'm working on integrating with your existing parsers. (using the lib to parse what we have and producing a nice output)

@TWiStErRob
Copy link
Contributor Author

I think you can close this as you have the commit on master that fixes the id as rule.

tomasbjerre added a commit that referenced this issue Aug 18, 2018
tomasbjerre added a commit that referenced this issue Aug 18, 2018
@tomasbjerre
Copy link
Owner

I released 1.59 now with this change.

@TWiStErRob
Copy link
Contributor Author

Wow, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants