net.sourceforge.pmd.RulePriority Java Examples
The following examples show how to use
net.sourceforge.pmd.RulePriority.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RulePrioritySlider.java From pmd-designer with BSD 2-Clause "Simplified" License | 6 votes |
public RulePrioritySlider() { setMin(HIGH.getPriority()); setMax(LOW.getPriority()); setValue(MEDIUM.getPriority()); setMajorTickUnit(1); setBlockIncrement(1); setMinorTickCount(0); setSnapToTicks(true); setLabelFormatter(DesignerUtil.stringConverter( d -> { RulePriority rp = RulePriority.valueOf(invert(d.intValue())); return rp != LOW && rp != HIGH && rp != MEDIUM ? "" : rp.getName(); }, s -> { throw new IllegalStateException("Shouldn't be called"); } )); }
Example #2
Source File: CollectorRenderer.java From sputnik with Apache License 2.0 | 6 votes |
@NotNull private Severity convert(@NotNull RulePriority rulePriority) { switch (rulePriority) { case HIGH: return Severity.ERROR; case MEDIUM_HIGH: return Severity.WARNING; case MEDIUM: return Severity.INFO; case MEDIUM_LOW: return Severity.INFO; case LOW: return Severity.IGNORE; default: throw new IllegalArgumentException("RulePriority " + rulePriority + " is not supported"); } }
Example #3
Source File: ExportXPathWizardController.java From pmd-designer with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void initialize(URL location, ResourceBundle resources) { initialiseLanguageChoiceBox(); Platform.runLater(() -> { // Fixes blurry text in the description text area descriptionArea.setCache(false); ScrollPane sp = (ScrollPane) descriptionArea.getChildrenUnmodifiable().get(0); sp.setCache(false); for (Node n : sp.getChildrenUnmodifiable()) { n.setCache(false); } }); // Expands required info pane Platform.runLater(() -> infoAccordion.setExpandedPane((TitledPane) infoAccordion.getChildrenUnmodifiable().get(0))); Platform.runLater(this::registerValidators); exportResultArea.setSyntaxHighlighter(new XmlSyntaxHighlighter()); exportResultArea.setEditable(false); ControlUtil.copyToClipboardButton(copyResultButton, exportResultArea::getText); resetMetadataButton.setOnAction(e -> { Alert alert = new Alert(AlertType.CONFIRMATION, "Wipe out the rule's metadata?", ButtonType.YES, ButtonType.CANCEL); alert.showAndWait(); exportResultArea.setSyntaxHighlighter(new XmlSyntaxHighlighter()); if (alert.getResult() == ButtonType.YES) { nameProperty().setValue(""); descriptionProperty().setValue(""); messageProperty().setValue(""); priorityProperty().setValue(RulePriority.MEDIUM); } }); languageVersionRangeSlider.currentLanguageProperty().bind(this.languageProperty()); Platform.runLater(() -> exportResultArea.moveTo(0)); }
Example #4
Source File: CodeAnalysisTest.java From graphviz-java with Apache License 2.0 | 5 votes |
@Override protected PmdResult analyzePmd() { final PmdViolationCollector collector = new PmdViolationCollector().minPriority(RulePriority.MEDIUM) .apply(PmdConfigs.minimalPmdIgnore()) .because("It's a ok", In.clazz(FillStyleTest.class).ignore("JUnitTestContainsTooManyAsserts")) .because("It's a bug?", In.clazz(FillStyle.class).ignore("AccessorMethodGeneration")); return new PmdAnalyzer(AnalyzerConfig.maven().mainAndTest(), collector) .withRulesets(PmdConfigs.defaultPmdRulesets()) .analyze(); }
Example #5
Source File: CollectorRendererTest.java From sputnik with Apache License 2.0 | 5 votes |
@Test void shouldReportViolationWithDetails() throws IOException { Configuration config = new ConfigurationSetup().setUp(ImmutableMap.of(GeneralOption.PMD_SHOW_VIOLATION_DETAILS.getKey(), "true")); Rule rule = createRule(RULE_DESCRIPTION, EXTERNAL_INFO_URL, RulePriority.HIGH, config); Report report = createReportWithVolation(createRuleViolation(rule, VIOLATION_DESCRIPTION, config), config); renderer.renderFileReport(report); Violation violation = renderer.getReviewResult().getViolations().get(0); assertThat(violation.getMessage()).isEqualTo(DESCRIPTION_WITH_DETAILS); assertThat(violation.getSeverity()).isEqualTo(Severity.ERROR); }
Example #6
Source File: CollectorRendererTest.java From sputnik with Apache License 2.0 | 5 votes |
@Test void shouldReportViolationWithoutDetails() throws IOException { Configuration config = new ConfigurationSetup().setUp(ImmutableMap.of(GeneralOption.PMD_SHOW_VIOLATION_DETAILS.getKey(), "false")); Rule rule = createRule(RULE_DESCRIPTION, EXTERNAL_INFO_URL, RulePriority.MEDIUM, config); Report report = createReportWithVolation(createRuleViolation(rule, VIOLATION_DESCRIPTION, config), config); renderer.renderFileReport(report); Violation violation = renderer.getReviewResult().getViolations().get(0); assertThat(violation.getMessage()).isEqualTo(VIOLATION_DESCRIPTION); }
Example #7
Source File: CollectorRendererTest.java From sputnik with Apache License 2.0 | 5 votes |
@NotNull private Rule createRule(String ruleDescription, String externalInfoUrl, RulePriority priority, @NotNull Configuration config) { renderer = new CollectorRenderer(config); Rule rule = mock(Rule.class); when(rule.getDescription()).thenReturn(ruleDescription); when(rule.getExternalInfoUrl()).thenReturn(externalInfoUrl); when(rule.getPriority()).thenReturn(priority); return rule; }
Example #8
Source File: PMDParameters.java From diff-check with GNU Lesser General Public License v2.1 | 4 votes |
@Override public RulePriority convert(String value) { return RulePriority.valueOf(validate(value)); }
Example #9
Source File: PMDParameters.java From diff-check with GNU Lesser General Public License v2.1 | 4 votes |
public RulePriority getMinimumPriority() { return minimumPriority; }
Example #10
Source File: ObservableRuleBuilder.java From pmd-designer with BSD 2-Clause "Simplified" License | 4 votes |
@PersistentProperty public RulePriority getPriority() { return priority.getValue(); }
Example #11
Source File: ObservableRuleBuilder.java From pmd-designer with BSD 2-Clause "Simplified" License | 4 votes |
public void setPriority(RulePriority priority) { this.priority.setValue(priority); }
Example #12
Source File: ObservableRuleBuilder.java From pmd-designer with BSD 2-Clause "Simplified" License | 4 votes |
public Var<RulePriority> priorityProperty() { return priority; }
Example #13
Source File: ExportXPathWizardController.java From pmd-designer with BSD 2-Clause "Simplified" License | 4 votes |
private Var<RulePriority> priorityProperty() { return rulePrioritySlider.priorityProperty(); }
Example #14
Source File: RulePrioritySlider.java From pmd-designer with BSD 2-Clause "Simplified" License | 4 votes |
public Var<RulePriority> priorityProperty() { return Var.doubleVar(valueProperty()).mapBidirectional( d -> RulePriority.valueOf(invert(d.intValue())), p -> Double.valueOf(invert(p.getPriority())) ); }
Example #15
Source File: CodeAnalysisTest.java From graphviz-java with Apache License 2.0 | 4 votes |
@Override protected PmdResult analyzePmd() { final PmdViolationCollector collector = new PmdViolationCollector().minPriority(RulePriority.MEDIUM) .apply(PmdConfigs.minimalPmdIgnore()) .because("It's examples", In.locs("ExampleTest", "ReadmeTest") .ignore("JUnitTestsShouldIncludeAssert", "LocalVariableCouldBeFinal", "UnusedLocalVariable")) .because("It's a test", In.loc("*Test") .ignore("ExcessiveMethodLength")) .because("It's a bug in PMD?", In.clazz(MutableNode.class).ignore("ConstructorCallsOverridableMethod"), In.loc("SerializerImpl#doGraph").ignore("ConsecutiveLiteralAppends")) .because("There are a lot of colors", In.clazz(Color.class) .ignore("FieldDeclarationsShouldBeAtStartOfClass")) .because("it's ok here", In.loc("Rasterizer#getDefault").ignore("CompareObjectsWithEquals"), In.locs("Format", "AttributeConfigs").ignore("AvoidDuplicateLiterals"), In.locs("LabelTest", "RankTest", "*DatatypeTest", "AttributeValidatorTest", "ParserTest", "JavascriptEngineTest", "GraphvizServerTest") .ignore("JUnitTestContainsTooManyAsserts"), In.locs("DatatypeTest").ignore("TestClassWithoutTestCases"), In.loc("SerializerImpl").ignore("AvoidStringBufferField", "CompareObjectsWithEquals"), In.locs("ThrowingFunction", "GraphvizLoader").ignore("AvoidThrowingRawExceptionTypes", "AvoidCatchingGenericException"), In.locs("GraphvizServer", "SerializerImpl").ignore("AvoidInstantiatingObjectsInLoops"), In.clazz(Shape.class).ignore("AvoidFieldNameMatchingTypeName"), In.loc("CommandRunnerTest").ignore("JUnitTestsShouldIncludeAssert"), In.locs("Lexer", "ParserImpl", "ImmutableGraph", "MutableGraph", "Label#applyTo", "Rank$GraphRank#applyTo", "Options#toJson", "Options#fromJson") .ignore("CyclomaticComplexity", "StdCyclomaticComplexity", "ModifiedCyclomaticComplexity", "NPathComplexity"), In.classes(GraphvizJdkEngine.class, GraphvizV8Engine.class, GraphvizServerEngine.class, AbstractGraphvizEngine.class) .ignore("PreserveStackTrace", "SignatureDeclareThrowsException", "AvoidCatchingGenericException"), In.locs("MutableGraph", "SerializerImpl", "ParserImpl", "Label", "Graphviz").ignore("GodClass"), In.locs("ImmutableGraph", "MutableGraph").ignore("ExcessiveMethodLength", "ExcessiveParameterList", "LooseCoupling"), In.locs("Format", "ImmutableGraph$GraphAttributed").ignore("AccessorMethodGeneration"), In.locs("AttributeConfigs", "AttributeValidator", "FontTools", "Graphviz", "GraphvizCmdLineEngine", "Options").ignore("TooManyStaticImports"), In.classes(MutableNode.class, Rasterizer.class, ValidatorMessage.class).ignore("ConfusingTernary"), In.clazz(ThrowingFunction.class).ignore("AvoidRethrowingException"), In.classes(ThrowingFunction.class, ThrowingBiConsumer.class).ignore("SignatureDeclareThrowsException")) .because("It's command line tool", In.loc("GraphvizServer") .ignore("AvoidCatchingGenericException", "PreserveStackTrace")) .because("I don't understand the message", In.locs("CommandRunnerTest", "AbstractJsGraphvizEngine").ignore("SimplifiedTernary")) .because("I don't agree", In.loc("Datatype").ignore("PositionLiteralsFirstInCaseInsensitiveComparisons"), In.clazz(CommandRunner.class).ignore("OptimizableToArrayCall"), In.everywhere().ignore("SimplifyStartsWith")) .because("It's wrapping an Exception with a RuntimeException", In.classes(Graphviz.class, CreationContext.class).ignore("AvoidCatchingGenericException")); return new PmdAnalyzer(AnalyzerConfig.maven().mainAndTest(), collector) .withRulesets(PmdConfigs.defaultPmdRulesets()) .analyze(); }
Example #16
Source File: CodeAnalysisTest.java From raml-tester with Apache License 2.0 | 4 votes |
@Override protected PmdResult analyzePmd() { final PmdViolationCollector collector = new PmdViolationCollector().minPriority(RulePriority.MEDIUM) .because("makes no sense", In.everywhere().ignore("JUnitSpelling")) .because("does not understand constants (logger is NOT)", In.everywhere().ignore("VariableNamingConventions")) .because("I don't agree", In.everywhere().ignore( "UncommentedEmptyMethodBody", "AvoidFieldNameMatchingMethodName", "AvoidFieldNameMatchingTypeName", "AbstractNaming", "UncommentedEmptyConstructor", "SimplifyStartsWith", "EmptyMethodInAbstractClassShouldBeAbstract", "AvoidSynchronizedAtMethodLevel", "UseStringBufferForStringAppends"), In.loc("SecurityExtractor$SchemeFinder").ignore("ConfusingTernary"), In.clazz(RamlViolationMessage.class).ignore("ConfusingTernary", "LocalVariableCouldBeFinal"), In.loc("UriComponents#getServer").ignore("NPathComplexity")) .because("arrays are only used internally", In.locs("*Response", "*Request").ignore("MethodReturnsInternalArray", "ArrayIsStoredDirectly")) .because("not urgent and too many occasions", In.everywhere().ignore( "AvoidInstantiatingObjectsInLoops", "JUnitAssertionsShouldIncludeMessage", "JUnitTestContainsTooManyAsserts", "MethodArgumentCouldBeFinal")) .because("it's plain wrong", In.loc("UsageCollector").ignore("ClassWithOnlyPrivateConstructorsShouldBeFinal")) .because("it's checked and correct", In.locs("RelativeJsonSchemaAwareRamlDocumentBuilder", "MediaType", "ServletRamlMessageTest").ignore("CompareObjectsWithEquals"), In.locs("JsRegex", "MediaType").ignore("PreserveStackTrace"), In.locs("JsRegex", "Usage").ignore("AvoidCatchingGenericException"), In.classes(UriTest.class, ParameterCheckerTest.class, MediaTypeTest.class).ignore("JUnitTestsShouldIncludeAssert")) .because("it's style", In.loc("RamlValidatorChecker").ignore("CollapsibleIfStatements")) .because("TODO", //TODO In.locs("ParameterChecker", "Usage", "MediaType").ignore("GodClass"), In.locs("VariableMatcher", "MediaType").ignore("CyclomaticComplexity", "NPathComplexity"), In.loc("ContentNegotiationChecker").ignore("AvoidDeeplyNestedIfStmts")) .because("They are snippets", In.loc("guru.nidi.ramltester.snippets*").ignoreAll()) .because("It's standard config", In.loc("CodeCoverage").ignore("NoPackage")) .because("is in test", In.locs("*Test", "*Test$*").ignore("AvoidDuplicateLiterals", "SignatureDeclareThrowsException", "TooManyStaticImports", "AvoidDollarSigns")); return new PmdAnalyzer(AnalyzerConfig.maven().mainAndTest(), collector) .withRulesets(basic(), braces(), design(), exceptions(), imports(), junit(), optimizations(), strings(), sunSecure(), typeResolution(), unnecessary(), unused(), codesize().tooManyMethods(35), empty().allowCommentedEmptyCatch(true), naming().variableLen(1, 25)) .analyze(); }