Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
- Remove redundant expressions in AnnotationScopes test
- Update docs to include example of mixing @SuppressWarnings and comments
  • Loading branch information
marcelocenerine committed Feb 28, 2018
1 parent 0d9d300 commit f6d9528
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,138 +57,49 @@ object AnnotationScopes {
// Class
@SuppressWarnings(Array("NoDummy"))
class DummyClass_1(val aDummy: Int, val bDummy: Int) {

val cDummy = 0
var dDummy = 0

def this(eDummy: String, fDummy: String) {
this(eDummy.toInt, fDummy.toInt)
}

def gDummy(hDummy: Int, iDummy: Int): Unit = {
val jDummy = 0
var hDummy = 0
}
}

// Primary constructor
class DummyClass_2 @SuppressWarnings(Array("NoDummy"))( // assert: NoDummy
val aDummy: Int, val bDummy: Int) {

val cDummy = 0 // assert: NoDummy
var dDummy = 0 // assert: NoDummy

def this(eDummy: String, // assert: NoDummy
fDummy: String) { // assert: NoDummy
this(eDummy.toInt, fDummy.toInt) // assert: NoDummy
}

def gDummy( // assert: NoDummy
hDummy: Int, // assert: NoDummy
iDummy: Int): Unit = { // assert: NoDummy
val jDummy = 0 // assert: NoDummy
var hDummy = 0 // assert: NoDummy
}
}

// Primary constructor parameter
class DummyClass_3( // assert: NoDummy
@SuppressWarnings(Array("NoDummy")) val aDummy: Int,
val bDummy: Int) { // assert: NoDummy

val cDummy = 0 // assert: NoDummy
var dDummy = 0 // assert: NoDummy

def this(eDummy: String, // assert: NoDummy
fDummy: String) { // assert: NoDummy
this(eDummy.toInt, fDummy.toInt) // assert: NoDummy
}

def gDummy( // assert: NoDummy
hDummy: Int, // assert: NoDummy
iDummy: Int): Unit = { // assert: NoDummy
val jDummy = 0 // assert: NoDummy
var hDummy = 0 // assert: NoDummy
}
}

// Field
class DummyClass_4( // assert: NoDummy
val aDummy: Int, // assert: NoDummy
val bDummy: Int) { // assert: NoDummy

class DummyClass_4 { // assert: NoDummy
@SuppressWarnings(Array("NoDummy"))
val cDummy = 0
@SuppressWarnings(Array("NoDummy"))
var dDummy = 0

def this(eDummy: String, // assert: NoDummy
fDummy: String) { // assert: NoDummy
this(eDummy.toInt, fDummy.toInt) // assert: NoDummy
}

def gDummy( // assert: NoDummy
hDummy: Int, // assert: NoDummy
iDummy: Int): Unit = { // assert: NoDummy
val jDummy = 0 // assert: NoDummy
var hDummy = 0 // assert: NoDummy
}
var dDummy = 0 // assert: NoDummy
}

// Secondary constructor
class DummyClass_5( // assert: NoDummy
val aDummy: Int, // assert: NoDummy
val bDummy: Int) { // assert: NoDummy

val cDummy = 0 // assert: NoDummy
var dDummy = 0 // assert: NoDummy
class DummyClass_5 { // assert: NoDummy

@SuppressWarnings(Array("NoDummy"))
def this(eDummy: String, fDummy: String) {
this(eDummy.toInt, fDummy.toInt)
}

def gDummy( // assert: NoDummy
hDummy: Int, // assert: NoDummy
iDummy: Int): Unit = { // assert: NoDummy
val jDummy = 0 // assert: NoDummy
var hDummy = 0 // assert: NoDummy
this
}
}

// Secondary constructor parameter
class DummyClass_6( // assert: NoDummy
val aDummy: Int, // assert: NoDummy
val bDummy: Int) { // assert: NoDummy

val cDummy = 0 // assert: NoDummy
var dDummy = 0 // assert: NoDummy
class DummyClass_6 { // assert: NoDummy

def this(@SuppressWarnings(Array("NoDummy")) eDummy: String,
fDummy: String) { // assert: NoDummy
this(eDummy.toInt, fDummy.toInt) // assert: NoDummy
}

def gDummy( // assert: NoDummy
hDummy: Int, // assert: NoDummy
iDummy: Int): Unit = { // assert: NoDummy
val jDummy = 0 // assert: NoDummy
var hDummy = 0 // assert: NoDummy
this
}
}

// Method
class DummyClass_7( // assert: NoDummy
val aDummy: Int, // assert: NoDummy
val bDummy: Int) { // assert: NoDummy

val cDummy = 0 // assert: NoDummy
var dDummy = 0 // assert: NoDummy

def this(eDummy: String, // assert: NoDummy
fDummy: String) { // assert: NoDummy
this(eDummy.toInt, fDummy.toInt) // assert: NoDummy
}
class DummyClass_7 { // assert: NoDummy

@SuppressWarnings(Array("NoDummy"))
def gDummy(hDummy: Int, iDummy: Int): Unit = {
Expand All @@ -198,17 +109,7 @@ object AnnotationScopes {
}

// Method parameter
class DummyClass_8( // assert: NoDummy
val aDummy: Int, // assert: NoDummy
val bDummy: Int) { // assert: NoDummy

val cDummy = 0 // assert: NoDummy
var dDummy = 0 // assert: NoDummy

def this(eDummy: String, // assert: NoDummy
fDummy: String) { // assert: NoDummy
this(eDummy.toInt, fDummy.toInt) // assert: NoDummy
}
class DummyClass_8 { // assert: NoDummy

def gDummy( // assert: NoDummy
@SuppressWarnings(Array("NoDummy")) hDummy: Int,
Expand All @@ -219,17 +120,7 @@ object AnnotationScopes {
}

// Local variable
class DummyClass_9( // assert: NoDummy
val aDummy: Int, // assert: NoDummy
val bDummy: Int) { // assert: NoDummy

val cDummy = 0 // assert: NoDummy
var dDummy = 0 // assert: NoDummy

def this(eDummy: String, // assert: NoDummy
fDummy: String) { // assert: NoDummy
this(eDummy.toInt, fDummy.toInt) // assert: NoDummy
}
class DummyClass_9 { // assert: NoDummy

def gDummy( // assert: NoDummy
hDummy: Int, // assert: NoDummy
Expand Down
13 changes: 11 additions & 2 deletions website/src/main/tut/docs/users/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,14 @@ List(1, "") // scalafix:ok NoInfer.any
 

**Note:** Suppression via comments and `@SuppressWarnings` can be combined in the same source file. Be mindful not to
introduce overlaps between the two as it can cause confusion. Scalafix gracefully handles overlaps by given
precedence to the `@SuppressWarnings` annotation.
introduce overlaps between the two as it can cause confusion and counter-intuitive behavior. Scalafix handles overlaps
by giving precedence to the `@SuppressWarnings` annotation:

```scala
@SuppressWarnings(Array("scalafix:Disable.null"))
def overlap(): Unit = {
val a = null
// scalafix:on Disable.null
val b = null // rule is still disabled because the annotation takes precedence over the comment
}
```

0 comments on commit f6d9528

Please sign in to comment.