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

Search rule by key #148

Merged
merged 3 commits into from Jan 27, 2019
Merged

Search rule by key #148

merged 3 commits into from Jan 27, 2019

Conversation

@satabin
Copy link
Contributor

satabin commented Jan 23, 2019

For custom rules created from a template rule, the internalKey is set
to the internal key of the template rule by Sonar and not the custom
rule key. When looking up the rule by internal key and providing the
custom rule key, nothing is found as they do not match.

Here is the rule created in sonarqube
rule-screen

and the API returns the following object:

{
      "key": "sonar-scala-scalastyle:test_test",
      "repo": "sonar-scala-scalastyle",
      "name": "test",
      "createdAt": "2019-01-23T16:23:58+0000",
      "severity": "MINOR",
      "internalKey": "org.scalastyle.file.RegexChecker-template",
      "templateKey": "sonar-scala-scalastyle:org.scalastyle.file.RegexChecker-template",
      "lang": "scala",
      "params": [
        {
          "key": "line",
          "htmlDesc": "Line: Boolean whether to process line by line",
          "type": "BOOLEAN"
        },
        {
          "key": "regex",
          "htmlDesc": "Regular expression: Standard Scala regular expression syntax including multiline",
          "defaultValue": "\\*>",
          "type": "STRING"
        },
        {
          "key": "ruleClass",
          "htmlDesc": "Scalastyle's rule (checker) class name.",
          "type": "STRING"
        }
      ],
      "type": "CODE_SMELL"
}

Using the rule key with repository to lookup fo rules ensures that even custom rules are found.

@BalmungSan

This comment has been minimized.

Copy link
Contributor

BalmungSan commented Jan 23, 2019

@satabin Good catch and Thanks! for the contribution.
Could you please also add an unit test case that should fail before the fix and pass now?

@satabin

This comment has been minimized.

Copy link
Contributor Author

satabin commented Jan 24, 2019

Yes, I will do that.

For custom rules created from a template rule, the `internalKey` is set
to the internal key of the template rule by Sonar and not the custom
rule key. When looking up the rule by internal key and providing the
custom rule key, nothing is found as they do not match.
@satabin satabin force-pushed the satabin:fix/find-rule-by-key branch from afe95d6 to 9cc3ff4 Jan 24, 2019
@satabin

This comment has been minimized.

Copy link
Contributor Author

satabin commented Jan 24, 2019

I added a test and took the occasion to fix another one that was not checking anything.

Copy link
Contributor

BalmungSan left a comment

Great, Thanks! 👍

Copy link
Owner

mwz left a comment

Nice one - thanks for contributing and implementing the tests which @BalmungSan asked for. I've made a minor inline comment about your testing style and I'll be happy to merge and release as soon you've addressed it. Thanks again 👍

satabin added 2 commits Jan 24, 2019
Fix test
The `===` must be used in combination with `assert` or `should` to
actually test equality, otherwise, it simply behaves as a type safe
equality returning `false` in case of inequality.
@satabin satabin force-pushed the satabin:fix/find-rule-by-key branch from 9cc3ff4 to 60daf57 Jan 25, 2019
@mwz

This comment has been minimized.

Copy link
Owner

mwz commented Jan 27, 2019

Thanks for the fix @satabin.

@mwz mwz merged commit c04474e into mwz:master Jan 27, 2019
1 check passed
1 check passed
ci/circleci: test Your tests passed on CircleCI!
Details
@satabin satabin deleted the satabin:fix/find-rule-by-key branch Jan 27, 2019
@mwz

This comment has been minimized.

Copy link
Owner

mwz commented Jan 27, 2019

Released as 7.3.1.

@satabin

This comment has been minimized.

Copy link
Contributor Author

satabin commented Jan 27, 2019

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.