Skip to content

Commit

Permalink
feat: add delete and add methods for parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
meiswjn committed Oct 6, 2023
1 parent 51cca6b commit e2139f4
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,39 @@ public void setParsers(final List<GroovyParser> parsers) {
save();
}

/**
* Removes a GroovyParser from the list by Id.
*
* @param parserId
* the ID of the Groovy parser to be deleted
*/
@DataBoundSetter
public void deleteParser(final String parserId) {
if (contains(parserId)) {
GroovyParser parser = getParser(parserId);
this.parsers.remove(parser);
} else {

Check warning on line 101 in plugin/src/main/java/io/jenkins/plugins/analysis/warnings/groovy/ParserConfiguration.java

View check run for this annotation

ci.jenkins.io / CheckStyle

RightCurlyCheck

NORMAL: '}' at column 9 should be alone on a line.
Raw output
<p>Since Checkstyle 3.0</p><p> Checks the placement of right curly braces (<code>'}'</code>) for if-else, try-catch-finally blocks, while-loops, for-loops, method definitions, class definitions, constructor definitions, instance and static initialization blocks. The policy to verify is specified using the property <code> option</code>. For right curly brace of expression blocks please follow issue <a href="https://github.com/checkstyle/checkstyle/issues/5945">#5945</a>. </p>
throw new NoSuchElementException("No parser with this ID.");
}
save();
}

/**
* Adds a GroovyParser to the list without removing other parsers.
*
* @param parser
* the new Groovy parser to be added
*/
@DataBoundSetter
public void addParser(final GroovyParser parser) {
if (!contains(parser.getId())) {
this.parsers.add(parser);
} else {

Check warning on line 117 in plugin/src/main/java/io/jenkins/plugins/analysis/warnings/groovy/ParserConfiguration.java

View check run for this annotation

ci.jenkins.io / CheckStyle

RightCurlyCheck

NORMAL: '}' at column 9 should be alone on a line.
Raw output
<p>Since Checkstyle 3.0</p><p> Checks the placement of right curly braces (<code>'}'</code>) for if-else, try-catch-finally blocks, while-loops, for-loops, method definitions, class definitions, constructor definitions, instance and static initialization blocks. The policy to verify is specified using the property <code> option</code>. For right curly brace of expression blocks please follow issue <a href="https://github.com/checkstyle/checkstyle/issues/5945">#5945</a>. </p>
throw new IllegalArgumentException("ID already exists.");
}

Check warning on line 119 in plugin/src/main/java/io/jenkins/plugins/analysis/warnings/groovy/ParserConfiguration.java

View check run for this annotation

ci.jenkins.io / PMD

ConfusingTernary

NORMAL: Avoid if (x != y) ..; else ..;.
Raw output
Avoid negation within an "if" expression with an "else" clause. For example, rephrase: `if (x != y) diff(); else same();` as: `if (x == y) same(); else diff();`. Most "if (x != y)" cases without an "else" are often return cases, so consistent use of this rule makes the code easier to read. Also, this resolves trivial ordering problems, such as "does the error case go first?" or "does the common case go first?". <pre> <code> boolean bar(int x, int y) { return (x != y) ? diff : same; } </code> </pre> <a href="https://pmd.github.io/pmd-6.55.0/pmd_rules_java_codestyle.html#confusingternary"> See PMD documentation. </a>
save();
}

/**
* Says if the admin has permitted groovy parsers to scan a build's console log.
*
Expand Down

0 comments on commit e2139f4

Please sign in to comment.