|
22 | 22 | import org.sonar.api.server.rule.RulesDefinition; |
23 | 23 | import org.sonar.check.Priority; |
24 | 24 | import org.sonar.check.Rule; |
| 25 | +import org.sonar.java.JavaVersionAwareVisitor; |
| 26 | +import org.sonar.java.checks.helpers.JavaVersionHelper; |
25 | 27 | import org.sonar.java.tag.Tag; |
26 | 28 | import org.sonar.plugins.java.api.JavaFileScanner; |
27 | 29 | import org.sonar.plugins.java.api.JavaFileScannerContext; |
|
35 | 37 | import org.sonar.plugins.java.api.tree.ReturnStatementTree; |
36 | 38 | import org.sonar.plugins.java.api.tree.Tree; |
37 | 39 | import org.sonar.plugins.java.api.tree.VariableTree; |
| 40 | +import org.sonar.squidbridge.annotations.ActivatedByDefault; |
38 | 41 | import org.sonar.squidbridge.annotations.SqaleConstantRemediation; |
39 | 42 | import org.sonar.squidbridge.annotations.SqaleSubCharacteristic; |
40 | 43 |
|
|
47 | 50 | name = "Lambdas should be replaced with method references", |
48 | 51 | priority = Priority.MINOR, |
49 | 52 | tags = {Tag.JAVA_8}) |
| 53 | +@ActivatedByDefault |
50 | 54 | @SqaleSubCharacteristic(RulesDefinition.SubCharacteristics.READABILITY) |
51 | 55 | @SqaleConstantRemediation("2min") |
52 | | -public class ReplaceLambdaByMethodRefCheck extends BaseTreeVisitor implements JavaFileScanner { |
| 56 | +public class ReplaceLambdaByMethodRefCheck extends BaseTreeVisitor implements JavaFileScanner, JavaVersionAwareVisitor { |
53 | 57 |
|
54 | 58 | private JavaFileScannerContext context; |
55 | 59 |
|
| 60 | + @Override |
| 61 | + public boolean isCompatibleWithJavaVersion(@Nullable Integer version) { |
| 62 | + return JavaVersionHelper.java8Compatible(version); |
| 63 | + } |
| 64 | + |
56 | 65 | @Override |
57 | 66 | public void scanFile(JavaFileScannerContext context) { |
58 | 67 | this.context = context; |
|
0 commit comments