-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: port remaining validation infos that don't need partial evaluat…
…ion (#607) Closes partially #543. ### Summary of Changes Show an info if * an argument list can be removed, * a type argument list can be removed, * a safe access can be removed. --------- Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com>
- Loading branch information
1 parent
4fd8d86
commit d53bda3
Showing
7 changed files
with
277 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tests/resources/validation/style/unnecessary argument list in annotation call/main.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package tests.validation.style.unnecessaryArgumentListInAnnotationCall | ||
|
||
@Repeatable | ||
annotation AnnotationWithoutParameterList | ||
|
||
@Repeatable | ||
annotation AnnotationWithEmptyParameterList() | ||
|
||
@Repeatable | ||
annotation AnnotationWithoutRequiredParameters(a: Int = 0, vararg b: Int) | ||
|
||
@Repeatable | ||
annotation AnnotationWithRequiredParameters(a: Int) | ||
|
||
// $TEST$ info "This argument list can be removed." | ||
@AnnotationWithoutParameterList»()« | ||
// $TEST$ no info "This argument list can be removed." | ||
@AnnotationWithoutParameterList»(1)« | ||
// $TEST$ info "This argument list can be removed." | ||
@AnnotationWithEmptyParameterList»()« | ||
// $TEST$ no info "This argument list can be removed." | ||
@AnnotationWithEmptyParameterList»(1)« | ||
// $TEST$ info "This argument list can be removed." | ||
@AnnotationWithoutRequiredParameters»()« | ||
// $TEST$ no info "This argument list can be removed." | ||
@AnnotationWithoutRequiredParameters»(1)« | ||
// $TEST$ no info "This argument list can be removed." | ||
@AnnotationWithRequiredParameters»()« | ||
// $TEST$ no info "This argument list can be removed." | ||
@AnnotationWithRequiredParameters»(1)« | ||
// $TEST$ no info "This argument list can be removed." | ||
@Unresolved»()« | ||
// $TEST$ no info "This argument list can be removed." | ||
@Unresolved»(1)« | ||
class MyClass |
65 changes: 65 additions & 0 deletions
65
tests/resources/validation/style/unnecessary argument list in call/main.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package tests.validation.style.unnecessaryArgumentListInCall | ||
|
||
annotation MyAnnotation | ||
|
||
class MyClass() | ||
|
||
enum MyEnum { | ||
EnumVariantWithoutParameterList | ||
EnumVariantWithEmptyParameterList() | ||
EnumVariantWithoutRequiredParameters(a: Int = 0, vararg b: Int) | ||
EnumVariantWithRequiredParameters(a: Int) | ||
} | ||
|
||
fun myFunction() | ||
|
||
segment mySegment1() {} | ||
|
||
segment mySegment2( | ||
callableType: () -> (), | ||
) { | ||
val blockLambda = () {}; | ||
val expressionLambda = () -> 0; | ||
|
||
// $TEST$ no info "This argument list can be removed." | ||
MyAnnotation»()«; | ||
|
||
// $TEST$ no info "This argument list can be removed." | ||
MyClass»()«; | ||
|
||
// $TEST$ info "This argument list can be removed." | ||
MyEnum.EnumVariantWithoutParameterList»()«; | ||
// $TEST$ no info "This argument list can be removed." | ||
MyEnum.EnumVariantWithoutParameterList»(1)«; | ||
// $TEST$ info "This argument list can be removed." | ||
MyEnum.EnumVariantWithEmptyParameterList»()«; | ||
// $TEST$ no info "This argument list can be removed." | ||
MyEnum.EnumVariantWithEmptyParameterList»(1)«; | ||
// $TEST$ no info "This argument list can be removed." | ||
MyEnum.EnumVariantWithoutRequiredParameters»()«; | ||
// $TEST$ no info "This argument list can be removed." | ||
MyEnum.EnumVariantWithoutRequiredParameters»(1)«; | ||
// $TEST$ no info "This argument list can be removed." | ||
MyEnum.EnumVariantWithRequiredParameters»()«; | ||
// $TEST$ no info "This argument list can be removed." | ||
MyEnum.EnumVariantWithRequiredParameters»(1)«; | ||
// $TEST$ no info "This argument list can be removed." | ||
MyEnum.Unresolved»()«; | ||
// $TEST$ no info "This argument list can be removed." | ||
MyEnum.Unresolved»(1)«; | ||
|
||
// $TEST$ no info "This argument list can be removed." | ||
myFunction»()«; | ||
|
||
// $TEST$ no info "This argument list can be removed." | ||
mySegment1»()«; | ||
|
||
// $TEST$ no info "This argument list can be removed." | ||
callableType»()«; | ||
|
||
// $TEST$ no info "This argument list can be removed." | ||
blockLambda»()«; | ||
|
||
// $TEST$ no info "This argument list can be removed." | ||
expressionLambda»()«; | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/resources/validation/style/unnecessary safe access/main.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package tests.validation.style.unnecessarySafeAccess | ||
|
||
pipeline test { | ||
// $TEST$ info "The receiver is never null, so the safe access is unnecessary." | ||
»1?.toString«(); | ||
// $TEST$ no info "The receiver is never null, so the safe access is unnecessary." | ||
»null?.toString«(); | ||
// $TEST$ no info "The receiver is never null, so the safe access is unnecessary." | ||
»unresolved?.toString«(); | ||
} |
49 changes: 49 additions & 0 deletions
49
tests/resources/validation/style/unnecessary type argument list/main.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package tests.validation.style.unnecessaryTypeArgumentList | ||
|
||
class ClassWithoutTypeParameterList | ||
class ClassWithEmptyTypeParameterList<> | ||
class ClassWithTypeParameters<T> | ||
|
||
enum Enum { | ||
EnumVariantWithoutTypeParameterList | ||
EnumVariantWithEmptyTypeParameterList<> | ||
VariantWithTypeParameters<T> | ||
} | ||
|
||
fun myFunction( | ||
// $TEST$ info "This type argument list can be removed." | ||
a1: ClassWithoutTypeParameterList»<>«, | ||
// $TEST$ no info "This type argument list can be removed." | ||
a2: ClassWithoutTypeParameterList»<Int>«, | ||
// $TEST$ info "This type argument list can be removed." | ||
a3: ClassWithEmptyTypeParameterList»<>«, | ||
// $TEST$ no info "This type argument list can be removed." | ||
a4: ClassWithEmptyTypeParameterList»<Int>«, | ||
// $TEST$ no info "This type argument list can be removed." | ||
a5: ClassWithTypeParameters»<>«, | ||
// $TEST$ no info "This type argument list can be removed." | ||
a6: ClassWithTypeParameters»<Int>«, | ||
|
||
// $TEST$ info "This type argument list can be removed." | ||
b1: Enum.EnumVariantWithoutTypeParameterList»<>«, | ||
// $TEST$ no info "This type argument list can be removed." | ||
b2: Enum.EnumVariantWithoutTypeParameterList»<Int>«, | ||
// $TEST$ info "This type argument list can be removed." | ||
b3: Enum.EnumVariantWithEmptyTypeParameterList»<>«, | ||
// $TEST$ no info "This type argument list can be removed." | ||
b4: Enum.EnumVariantWithEmptyTypeParameterList»<Int>«, | ||
// $TEST$ no info "This type argument list can be removed." | ||
b5: Enum.VariantWithTypeParameters»<>«, | ||
// $TEST$ no info "This type argument list can be removed." | ||
b6: Enum.VariantWithTypeParameters»<Int>«, | ||
|
||
// $TEST$ info "This type argument list can be removed." | ||
c1: Enum»<>«, | ||
// $TEST$ no info "This type argument list can be removed." | ||
c2: Enum»<Int>«, | ||
|
||
// $TEST$ no info "This type argument list can be removed." | ||
d1: Unresolved»<>«, | ||
// $TEST$ no info "This type argument list can be removed." | ||
d2: Unresolved»<Int>«, | ||
) |