FluentLenium/FluentLenium

View on GitHub

Showing 1,951 of 1,951 total issues

The user-supplied array 'args' is stored directly.
Open

    public ReflectiveCapabilitiesFactory(String name, String capabilitiesClassName, Object... args) {

ArrayIsStoredDirectly

Since: PMD 2.2

Priority: Medium

Categories: Style

Remediation Points: 50000

Constructors and methods receiving arrays should clone objects and store the copy. This prevents future changes from the user from affecting the original array.

Example:

public class Foo {
 private String [] x;
 public void foo (String [] param) {
 // Don't do this, make a copy of the array at least
 this.x=param;
 }
}

The method 'on(By, FluentWebElement, WebDriver)' has a cyclomatic complexity of 12.
Open

    public void on(By by, FluentWebElement element, WebDriver driver) {
        if (targetElement != null && (element == null || !targetElement.equals(element.getElement()))) {
            return;
        }

CyclomaticComplexity

Since: PMD 1.03

Priority: Medium

Categories: Style

Remediation Points: 50000

The complexity of methods directly affects maintenance costs and readability. Concentrating too much decisional logic in a single method makes its behaviour hard to read and change. Cyclomatic complexity assesses the complexity of a method by counting the number of decision points in a method, plus one for the method entry. Decision points are places where the control flow jumps to another place in the program. As such, they include all control flow statements, such as if, while, for, and case. For more details on the calculation, see the documentation of the Cyclo metric. Generally, numbers ranging from 1-4 denote low complexity, 5-7 denote moderate complexity, 8-10 denote high complexity, and 11+ is very high complexity. By default, this rule reports methods with a complexity >= 10. Additionnally, classes with many methods of moderate complexity get reported as well once the total of their methods' complexities reaches 80, even if none of the methods was directly reported. Reported methods should be broken down into several smaller methods. Reported classes should probably be broken down into subcomponents.

Example:

class Foo {
 void baseCyclo() { // Cyclo = 1
 highCyclo();
 }

 void highCyclo() { // Cyclo = 10: reported!
 int x = 0, y = 2;
 boolean a = false, b = true;

 if (a && (y == 1 ? b : true)) { // +3
 if (y == x) { // +1
 while (true) { // +1
 if (x++ < 20) { // +1
 break; // +1
 }
 }
 } else if (y == t && !d) { // +2
 x = a ? y : x; // +1
 } else {
 x = 2;
 }
 }
 }
}

Avoid variables with short names like s
Open

    public void on(String s, WebDriver driver) {

ShortVariable

Since: PMD 0.3

Priority: Medium

Categories: Style

Remediation Points: 50000

Fields, local variables, or parameter names that are very short are not helpful to the reader.

Example:

public class Something {
 private int q = 15; // field - too short
 public static void main( String as[] ) { // formal arg - too short
 int r = 20 + q; // local var - too short
 for (int i = 0; i < 10; i++) { // not a violation (inside 'for' loop)
 r += q;
 }
 for (Integer i : numbers) { // not a violation (inside 'for-each' loop)
 r += q;
 }
 }
}

Avoid if (x != y) ..; else ..;
Open

        if (!explicitMockName.isEmpty()) {
            return explicitMockName;
        } else if (parameter.isNamePresent()) {
            return parameter.getName();
        }

ConfusingTernary

Since: PMD 1.9

Priority: Medium

Categories: Style

Remediation Points: 50000

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?'.

Example:

boolean bar(int x, int y) {
 return (x != y) ? diff : same;
}

The user-supplied array 'args' is stored directly.
Open

    public ReflectiveWebDriverFactory(String name, String webDriverClassName, Object... args) {

ArrayIsStoredDirectly

Since: PMD 2.2

Priority: Medium

Categories: Style

Remediation Points: 50000

Constructors and methods receiving arrays should clone objects and store the copy. This prevents future changes from the user from affecting the original array.

Example:

public class Foo {
 private String [] x;
 public void foo (String [] param) {
 // Don't do this, make a copy of the array at least
 this.x=param;
 }
}

The user-supplied array 'args' is stored directly.
Open

    public ReflectiveWebDriverFactory(String name, Class<? extends WebDriver> webDriverClass, Object... args) {

ArrayIsStoredDirectly

Since: PMD 2.2

Priority: Medium

Categories: Style

Remediation Points: 50000

Constructors and methods receiving arrays should clone objects and store the copy. This prevents future changes from the user from affecting the original array.

Example:

public class Foo {
 private String [] x;
 public void foo (String [] param) {
 // Don't do this, make a copy of the array at least
 this.x=param;
 }
}

This call to Collection.toArray() may be optimizable
Open

        return names.toArray(new String[names.size()]);

OptimizableToArrayCall

Since: PMD 1.8

Priority: Medium

Categories: Style

Remediation Points: 50000

Calls to a collection's toArray(E[]) method should specify a target array of zero size. This allows the JVM to optimize the memory allocation and copying as much as possible. Previous versions of this rule (pre PMD 6.0.0) suggested the opposite, but current JVM implementations perform always better, when they have full control over the target array. And allocation an array via reflection is nowadays as fast as the direct allocation. See also Arrays of Wisdom of the Ancients Note: If you don't need an array of the correct type, then the simple toArray() method without an array is faster, but returns only an array of type Object[].

Example:

List<foo> foos = getFoos();

// much better; this one allows the jvm to allocate an array of the correct size and effectively skip
// the zeroing, since each array element will be overridden anyways
Foo[] fooArray = foos.toArray(new Foo[0]);

// inefficient, the array needs to be zeroed out by the jvm before it is handed over to the toArray method
Foo[] fooArray = foos.toArray(new Foo[foos.size()]);</foo>

Consider simply returning the value vs storing it in local variable 'untilPredicate'
Open

        return untilPredicate;

UnnecessaryLocalBeforeReturn

Since: PMD 3.3

Priority: Medium

Categories: Style

Remediation Points: 50000

Avoid the creation of unnecessary local variables

Example:

public class Foo {
 public int foo() {
 int x = doSomething();
 return x; // instead, just 'return doSomething();'
 }
}

Avoid short class names like Dom
Open

public class Dom {
    private final WebElement webElement;
    private final ComponentInstantiator instantiator;

    /**

ShortClassName

Since: PMD 5.0

Priority: Medium Low

Categories: Style

Remediation Points: 50000

Short Classnames with fewer than e.g. five characters are not recommended.

Example:

public class Foo {
}

Avoid if (x != y) ..; else ..;
Open

        return (page != null) ? page : fluentWebElement;

ConfusingTernary

Since: PMD 1.9

Priority: Medium

Categories: Style

Remediation Points: 50000

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?'.

Example:

boolean bar(int x, int y) {
 return (x != y) ? diff : same;
}

Avoid variables with short names like is
Open

        InputStream is = Files.newInputStream(Paths.get(fileName));

ShortVariable

Since: PMD 0.3

Priority: Medium

Categories: Style

Remediation Points: 50000

Fields, local variables, or parameter names that are very short are not helpful to the reader.

Example:

public class Something {
 private int q = 15; // field - too short
 public static void main( String as[] ) { // formal arg - too short
 int r = 20 + q; // local var - too short
 for (int i = 0; i < 10; i++) { // not a violation (inside 'for' loop)
 r += q;
 }
 for (Integer i : numbers) { // not a violation (inside 'for-each' loop)
 r += q;
 }
 }
}
Severity
Category
Status
Source
Language