Skip to content

Commit

Permalink
#33 Inspections: extend description
Browse files Browse the repository at this point in the history
  • Loading branch information
stokito committed Oct 21, 2020
1 parent 39e7f52 commit 3d684dd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
6 changes: 3 additions & 3 deletions META-INF/plugin.xml
Expand Up @@ -34,14 +34,14 @@
<configurationType implementation="ru.artyushov.jmhPlugin.configuration.JmhConfigurationType"/>
<runConfigurationProducer implementation="ru.artyushov.jmhPlugin.configuration.JmhConfigurationProducer"/>
<runLineMarkerContributor language="UAST" implementationClass="ru.artyushov.jmhPlugin.configuration.JmhRunLineMarkerContributor"/>
<localInspection shortName="JmhBenchMethodInvalidSignature"
displayName="@Benchmark, @Setup and @TearDown: method should be public"
<localInspection shortName="JmhInspections"
displayName="Check that JMH benchmark has a proper structure"
groupPath="Java"
groupName="JMH"
enabledByDefault="true"
language="UAST"
level="ERROR"
implementationClass="ru.artyushov.jmhPlugin.inspection.JmhBenchMethodInvalidSignatureInspection"/>
implementationClass="ru.artyushov.jmhPlugin.inspection.JmhInspections"/>
</extensions>

<actions>
Expand Down

This file was deleted.

15 changes: 15 additions & 0 deletions resources/inspectionDescriptions/JmhInspections.html
@@ -0,0 +1,15 @@
<html>
<body>
<p>Check that JMH benchmark has a proper structure.</p>
<!-- tooltip end -->
<p>
<ul>
<li><code>@Benchmark</code>, <code>@Setup</code>, <code>@TearDown</code> methods should be public</li>
<li><code>@Setup</code>, <code>@TearDown</code> should be void and not return anything</li>
<li>Benchmark class should have package other than default</li>
<li>Benchmark class should not be final</li>
<li>@State annotation is missing</li>
</ul>
</p>
</body>
</html>
Expand Up @@ -22,9 +22,12 @@
import static ru.artyushov.jmhPlugin.configuration.ConfigurationUtils.hasSetupOrTearDownAnnotation;
import static ru.artyushov.jmhPlugin.configuration.ConfigurationUtils.hasStateAnnotation;

public class JmhBenchMethodInvalidSignatureInspection extends AbstractBaseUastLocalInspectionTool {
public class JmhInspections extends AbstractBaseUastLocalInspectionTool {
private static final LocalQuickFix BENCH_METHOD_QUICK_FIX = new BenchMethodSignatureFix();

/**
* For performance reasons all checks are executed in one method
*/
@Override
public @Nullable ProblemDescriptor[] checkClass(@NotNull UClass klass, @NotNull InspectionManager manager, boolean isOnTheFly) {
boolean isBenchmarkClass = false;
Expand All @@ -48,6 +51,10 @@ public class JmhBenchMethodInvalidSignatureInspection extends AbstractBaseUastLo
ProblemDescriptor problem = manager.createProblemDescriptor(method, "@Benchmark method should be public", BENCH_METHOD_QUICK_FIX, ERROR, isOnTheFly);
return new ProblemDescriptor[]{problem};
}
if (method.hasModifierProperty(ABSTRACT)) {
ProblemDescriptor problem = manager.createProblemDescriptor(method, "@Benchmark method can not be abstract", BENCH_METHOD_QUICK_FIX, ERROR, isOnTheFly);
return new ProblemDescriptor[]{problem};
}
}
}

Expand Down

0 comments on commit 3d684dd

Please sign in to comment.