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

Use ScapegoatConfig.inspections instead of ClassGraph to populate active Scapegoat inspections #132

Merged
merged 3 commits into from Dec 1, 2018

Conversation

mwz
Copy link
Member

@mwz mwz commented Nov 26, 2018

I didn't realise before that ScapegoatConfig.inspections existed, but this way we can obtain the current list of active inspections, without having to blacklist anything (it looks like we were creating 9 rules which are no longer active in Scapegoat). The use of ClassGraph is no longer necessary in this case.

Closes #131.

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.

"com.sksamuel.scapegoat.inspections.collections.FilterDotSizeComparison", // Not implemented yet
"com.sksamuel.scapegoat.inspections.collections.ListTail" // Not implemented yet
)
val BlacklistedInspections: Set[String] = Set.empty
Copy link
Contributor

Choose a reason for hiding this comment

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

If it is going to be empty, we should just remove it for now.
If we need it in a future we could just re-implement it, for now it is only noise IMHO.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to change as little as possible, but yes, I'm happy to remove this.

case clazz if !BlacklistedInspections.contains(clazz.getName) =>
(clazz.getName, clazz.newInstance())
}
ScapegoatConfig.inspections.collect {
Copy link
Contributor

Choose a reason for hiding this comment

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

Following above comment, this can be a simple map.
Also, do we need it to be a List? or are we happy with it being a Seq ?
Or, since you're planning to open a PR in Scapegoat you may change it to List there (that would be better IMHO).

Copy link
Member Author

Choose a reason for hiding this comment

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

Following above comment, this can be a simple map.

👍

Also, do we need it to be a List? or are we happy with it being a Seq?

I generally tend to go for a Seq as a return type, which is a trait and it makes it easier to use any subtype depending on the needs. I'm not sure why we used a List here, but I'm not too fussed about it since List is a default implementation of Seq and I don't think we have the need to convert this to an indexed sequence anywhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

I used to go for Seq too, but a few days ago I found this and I must admit that he got a point, specially with the complexity.
Anyway, in this case I'm ok with it being a Seq since ScapegoatConfig.inspections is a Seq too, and it will be a List in runtime, and we aren't exposing it.

@mwz mwz merged commit 379ad6a into master Dec 1, 2018
@mwz mwz deleted the scapegoat-config-inspections branch December 1, 2018 17:09
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