FluentWebElement
has 128 methods (exceeds 20 allowed). Consider refactoring. Open
@SuppressWarnings({"PMD.GodClass", "PMD.ExcessivePublicCount"})
public class FluentWebElement extends Component
implements WrapsElement, FluentActions<FluentWebElement, FluentWebElement>, FluentProxyState<FluentWebElement>,
SearchControl<FluentWebElement>, HookControl<FluentWebElement>, FluentLabel<FluentWebElement>,
NavigationControl, JavascriptControl, AlertControl, SnapshotControl, EventsControl, SeleniumDriverControl,
File FluentWebElement.java
has 653 lines of code (exceeds 250 allowed). Consider refactoring. Open
package io.fluentlenium.core.domain;
import io.appium.java_client.AppiumDriver;
import io.fluentlenium.core.FluentControl;
import io.fluentlenium.core.FluentPage;
Identical blocks of code found in 2 locations. Consider refactoring. Open
hookControl = new HookControlImpl<>(this, webElement, this.control, this.instantiator,
/*do not change it to lambda - change will affect w/ PMD warning
Overridable method 'getElement' called during object construction*/
() -> {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 70.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
hookControl = new HookControlImpl<>(this, webElement, this.control, this.instantiator,
/*do not change it to lambda - change will affect w/ PMD warning
Overridable method 'getElement' called during object construction*/
() -> {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 70.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Missing a Javadoc comment. Open
public void unshadowAllFields() {
- Read upRead up
- Exclude checks
Checks for missing Javadoc comments for a method or constructor.The scope to verify is specified using the Scope
class anddefaults to Scope.PUBLIC
. To verify anotherscope, set property scope to a differentscope.
Javadoc is not required on a method that is tagged with the@Override
annotation. However underJava 5 it is not possible to mark a method required for aninterface (this was corrected under Java 6). HenceCheckstyle supports using the convention of using a single{@inheritDoc}
tag instead of all theother tags.
For getters and setters for the property allowMissingPropertyJavadoc
,the methods must match exactly the structures below.
public void setNumber(final int number){mNumber = number;}public int getNumber(){return mNumber;}public boolean isSomething(){return false;}
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Name 'io.fluentlenium.core.domain' must match pattern '^org.[a-z]+(.[a-zA-Z_][a-zA-Z0-9_]*)*$'. Open
package io.fluentlenium.core.domain;
- Read upRead up
- Exclude checks
Checks that package names conform to a specified pattern.
The default value of format
for module PackageName
has beenchosen to match the requirements in the JavaLanguage specification and the Sun coding conventions. Howeverboth underscores and uppercase letters are rather uncommon, so mostconfigurations should probably assign value ^[a-z]+(\.[a-z][a-z0-9]*)*$
toformat
for module PackageName
.
This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Expected @param tag for 'actions'. Open
public FluentWebElement(WebElement element, FluentControl control, ComponentInstantiator instantiator, Actions actions) {
- Read upRead up
- Exclude checks
Checks the Javadoc of a method or constructor. The scopeto verify is specified using the Scope
class anddefaults to Scope.PRIVATE
. To verify anotherscope, set property scope to a differentscope.
Violates parameters and type parametersfor which no param tags arepresent can be suppressed by defining propertyallowMissingParamTags
.
Violates methods which return non-void but for which no return tag ispresent can be suppressed by defining propertyallowMissingReturnTag
.
Violates exceptions which are declared to be thrown (by throws
in the methodsignature or by throw new
in the method body), but for which no throws tag ispresent by activation of property validateThrows
.Note that throw new
is not checked in the following places:
- Inside a try block (with catch). It is not possible to determine if the thrownexception can be caught by the catch block as there is no knowledge of theinheritance hierarchy, so the try block is ignored entirely. However, catchand finally blocks, as well as try blocks without catch, are still checked.
- Local classes, anonymous classes and lambda expressions. It is not known when thethrow statements inside such classes are going to be evaluated, so they are ignored.
ATTENTION: Checkstyle does not have information about hierarchy of exception typesso usage of base class is considered as separate exception type.As workaround you need to specify both types in javadoc (parent and exact type).
Javadoc is not required on a method that is tagged with the@Override
annotation. However underJava 5 it is not possible to mark a method required for aninterface (this was corrected under Java 6). HenceCheckstyle supports using the convention of using a single{@inheritDoc}
tag instead of all theother tags.
Note that only inheritable items will allow the{@inheritDoc}
tag to be used in placeof comments. Static methods at all visibilities, private non-staticmethods and constructors are not inheritable.
For example, if the following method isimplementing a method required by an interface, then theJavadoc could be done as:
<source><br>/** {@inheritDoc} */<br>public int checkReturnTag(final int aTagIndex,<br> JavadocTag[] aTags,<br> int aLineNo)<br> </source>This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.
Overridable method 'unshadowAllFields' called during object construction Open
unshadowAllFields();
- Read upRead up
- Exclude checks
ConstructorCallsOverridableMethod
Since: PMD 1.04
Priority: High
Categories: Style
Remediation Points: 50000
Calling overridable methods during construction poses a risk of invoking methods on an incompletely constructed object and can be difficult to debug. It may leave the sub-class unable to construct its superclass or forced to replicate the construction process completely within itself, losing the ability to call super(). If the default constructor contains a call to an overridable method, the subclass may be completely uninstantiable. Note that this includes method calls throughout the control flow graph - i.e., if a constructor Foo() calls a private method bar() that calls a public method buz(), this denotes a problem.
Example:
public class SeniorClass {
public SeniorClass(){
toString(); //may throw NullPointerException if overridden
}
public String toString(){
return 'IAmSeniorClass';
}
}
public class JuniorClass extends SeniorClass {
private String name;
public JuniorClass(){
super(); //Automatic call leads to NullPointerException
name = 'JuniorClass';
}
public String toString(){
return name.toUpperCase();
}
}
Overridable method 'unshadowAllFields' called during object construction Open
unshadowAllFields();
- Read upRead up
- Exclude checks
ConstructorCallsOverridableMethod
Since: PMD 1.04
Priority: High
Categories: Style
Remediation Points: 50000
Calling overridable methods during construction poses a risk of invoking methods on an incompletely constructed object and can be difficult to debug. It may leave the sub-class unable to construct its superclass or forced to replicate the construction process completely within itself, losing the ability to call super(). If the default constructor contains a call to an overridable method, the subclass may be completely uninstantiable. Note that this includes method calls throughout the control flow graph - i.e., if a constructor Foo() calls a private method bar() that calls a public method buz(), this denotes a problem.
Example:
public class SeniorClass {
public SeniorClass(){
toString(); //may throw NullPointerException if overridden
}
public String toString(){
return 'IAmSeniorClass';
}
}
public class JuniorClass extends SeniorClass {
private String name;
public JuniorClass(){
super(); //Automatic call leads to NullPointerException
name = 'JuniorClass';
}
public String toString(){
return name.toUpperCase();
}
}