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

Add support to disable symbol via regex #669

Merged
merged 24 commits into from
Apr 11, 2018

Conversation

vovapolu
Copy link
Contributor

@vovapolu vovapolu commented Apr 1, 2018

Removing OrphanImplicits from #635, since it's not going to be merged soon...

@vovapolu vovapolu requested a review from olafurpg April 1, 2018 10:53
Copy link
Contributor

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

Two comments on constructors and select qualifiers, rest of the changes look good!

import scala.collection.mutable // ok

@SuppressWarnings(Array("Disable.ListBuffer"))
@SuppressWarnings(Array("Disable.<init>"))
Copy link
Contributor

Choose a reason for hiding this comment

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

I propose we either

  • ignore constructors (skip when name is <init>), or
  • give Disable.<init>a more helpful name such as ListBuffer.<init>

I vote for the first option since you can't reference a constructor without referencing the enclosing type. Having to disable twice is annoying.

@SuppressWarnings(Array("Disable.mutable"))
@SuppressWarnings(Array("Disable.HashMap"))
@SuppressWarnings(Array("Disable.<init>"))
val abc = new mutable.HashMap[String, String]()
Copy link
Contributor

Choose a reason for hiding this comment

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

Intuitively, there is only one symbol being referenced here HashMap.<init> so I think it's a bit weird that three errors are reported.

I think it would make sense to skip the qualifier of a Term.Select if it only contains Term.Select or Term.Name.

a.b.C // only report on C
d.E // only report on E
f.g(1).h // report on h and g

It should be simple to do this check with something like

def skipQualifier(qual: Term) Boolean = qual match {
  case _: Term.Name => true
  case Term.Select(q, _) => skipQualifier(q)
}

@olafurpg olafurpg mentioned this pull request Apr 4, 2018
Copy link
Contributor

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

Thanks for the update @vovapolu , one more question.

@@ -29,12 +29,9 @@ object DisableRegex {
import scala.collection.mutable // ok

@SuppressWarnings(Array("Disable.ListBuffer"))
@SuppressWarnings(Array("Disable.<init>"))
val buffer = new ListBuffer[Int]()
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if you have a more complex qualifier in a select?

a.b(1).c

and a and c are banned? I would expect there to be two lint errors

a.b(1).c
^

a.b(1).c
       ^

Copy link
Contributor

Choose a reason for hiding this comment

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

Colombo: one more thing

Copy link
Contributor

Choose a reason for hiding this comment

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

I opened #679 and assigned the ticket to you @vovapolu . I will go ahead and merge to unblock a release, but please be sure to follow up on that ticket as I think the current change results in surprising behavior.

Copy link
Contributor

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Thanks for the patience in addressing my comments @vovapolu I opened a ticket #679 to follow up on my last comment.

@olafurpg olafurpg merged commit 389b5dc into scalacenter:master Apr 11, 2018
@olafurpg olafurpg added this to the v0.6.0-M2 milestone Apr 11, 2018
@olafurpg olafurpg changed the title Disable regex Add support to disable symbol via regex Apr 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants