Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Refactor scapegoat rules and repositories #383

Merged
merged 4 commits into from Feb 23, 2020

Conversation

mwz
Copy link
Member

@mwz mwz commented Feb 22, 2020

The refactoring continues...

Relates to #343.

@mwz mwz merged commit 58a0433 into master Feb 23, 2020
@mwz mwz deleted the refactor-scapegoat-rules-and-repositories branch February 23, 2020 16:34
Copy link
Contributor

@BalmungSan BalmungSan left a comment

Choose a reason for hiding this comment

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

Cool 👍

Just some minor comments.


private[scapegoat] object Level {
private[metadata] sealed trait Level
object Level {
case object Error extends Level
case object Warning extends Level
case object Info extends Level
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto case objects should be final.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks for the reminder, I keep forgetting 😅

"main",
"scala",
"project/src/main/scala",
"com/mwz/sonar/scala/metadata/scalastyle",
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the point of Path.get to do not use / because that won't work on Windows?

Copy link
Member Author

Choose a reason for hiding this comment

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

ah yes, very good point - I'll fix that

ScalastyleInspections.AllInspections should have size 72 // 31 templates + 41 default rules
ScalastyleInspections.AllInspectionsByClass.size shouldBe ScalastyleInspections.AllInspections.size
ScalastyleRules.rules.length shouldBe 72 // 31 templates + 41 default rules
ScalastyleRules.rules.map(r => r.key -> r).iterator.toMap.size shouldBe ScalastyleRules.rules.length
Copy link
Contributor

Choose a reason for hiding this comment

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

Any particular reason for not using have size or have length?

Also, for the second test, I believe it would be better to ensure that all the keys are unique.

ScalastyleRules.rules.distinctBy(_.key) shouldBe ScalastyleRules.rules

Copy link
Member Author

Choose a reason for hiding this comment

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

Any particular reason for not using have size or have length?

Yes, so Chain doesn't have the size property (it has length) and I found the autocompletion to work better in metals when you first access the property and then use matchers for comparing the value. It couldn't easily infer the have length syntax, so I settled on .length shouldBe.

Also, for the second test, I believe it would be better to ensure that all the keys are unique.

I think this is testing the same thing, but yeah your example is more concise, so I'll use that instead, thanks 👍

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

Successfully merging this pull request may close these issues.

None yet

2 participants