damianwajser/spring-rest-commons-options

View on GitHub
src/main/java/com/github/damianwajser/model/details/strategys/DetailFieldStrategy.java

Summary

Maintainability
A
1 hr
Test Coverage

Method getName has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private String getName(PropertyDescriptor field, Optional<Field> optField, boolean isRequest) {
        String name = field.getName();
        if (optField.isPresent()) {
            JsonProperty property = optField.get().getAnnotation(JsonProperty.class);
            if (property != null) {

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method createDetail has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected Optional<DetailField> createDetail(PropertyDescriptor descriptor, Optional<Field> f, boolean isRequest) {
        Optional<DetailField> detailField;
        LOGGER.debug("creando property: {}, field: {}, isRequest: {}", descriptor, f, isRequest);
        if (isRequest) {
            Optional<List<Validator>> validators = ValidatorFactory.getValidations(descriptor, f);

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Change the visibility of this constructor to "protected".
Open

    public DetailFieldStrategy(Type type) {

Abstract classes should not have public constructors. Constructors of abstract classes can only be called in constructors of their subclasses. So there is no point in making them public. The protected modifier should be enough.

Noncompliant Code Example

public abstract class AbstractClass1 {
    public AbstractClass1 () { // Noncompliant, has public modifier
        // do something here
    }
}

Compliant Solution

public abstract class AbstractClass2 {
    protected AbstractClass2 () {
        // do something here
    }
}

Line is longer than 100 characters (found 105).
Open

        LOGGER.debug("creando property: {}, field: {}, isRequest: {}", descriptor, f, isRequest);

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Line is longer than 100 characters (found 110).
Open

            Optional<List<Validator>> validators = ValidatorFactory.getValidations(descriptor, f);

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Line is longer than 100 characters (found 137).
Open

        isAuditable = isAuditable || field.getReadMethod() != null && field.getReadMethod().isAnnotationPresent(Auditable.class);

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Line is longer than 100 characters (found 116).
Open

                detailField = Optional.ofNullable(new DetailFieldWithValidations(validators.get()));

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Line is longer than 100 characters (found 103).
Open

                LOGGER.debug("se crea Request DetailField : {}", descriptor.getName());

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Parameter name 'f' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.
Open

    protected Optional<DetailField> createDetail(PropertyDescriptor descriptor, Optional<Field> f, boolean isRequest) {

Checks that method parameter names conform to a specified pattern.By using accessModifiers property it is possibleto specify different formats for methods at different visibility levels.

To validate catch parameters please useCatchParameterName.

To validate lambda parameters please useLambdaParameterName.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Line is longer than 100 characters (found 109).
Open

    private void fillDetails(PropertyDescriptor field, Optional<Field> optField, DetailField detailField,

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'com.github.damianwajser.annotations.Auditable' import. Should be before 'org.slf4j.LoggerFactory'.
Open

import com.github.damianwajser.annotations.Auditable;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Parameter name 'm' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.
Open

    private String getName(Method m, String defaultName) {

Checks that method parameter names conform to a specified pattern.By using accessModifiers property it is possibleto specify different formats for methods at different visibility levels.

To validate catch parameters please useCatchParameterName.

To validate lambda parameters please useLambdaParameterName.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'com.fasterxml.jackson.annotation.JsonProperty' import. Should be before 'org.slf4j.LoggerFactory'.
Open

import com.fasterxml.jackson.annotation.JsonProperty;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'com.github.damianwajser.model.validators.ValidatorFactory' import. Should be before 'org.slf4j.LoggerFactory'.
Open

import com.github.damianwajser.model.validators.ValidatorFactory;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Line is longer than 100 characters (found 123).
Open

    protected Optional<DetailField> createDetail(PropertyDescriptor descriptor, Optional<Field> f, boolean isRequest) {

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Line is longer than 100 characters (found 103).
Open

    private String getName(PropertyDescriptor field, Optional<Field> optField, boolean isRequest) {

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'com.github.damianwajser.model.validators.Validator' import. Should be before 'org.slf4j.LoggerFactory'.
Open

import com.github.damianwajser.model.validators.Validator;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'com.github.damianwajser.model.details.DetailField' import. Should be before 'org.slf4j.LoggerFactory'.
Open

import com.github.damianwajser.model.details.DetailField;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Extra separation in import group before 'com.fasterxml.jackson.annotation.JsonProperty'
Open

import com.fasterxml.jackson.annotation.JsonProperty;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Extra separation in import group before 'org.apache.commons.lang3.builder.ToStringBuilder'
Open

import org.apache.commons.lang3.builder.ToStringBuilder;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Line is longer than 100 characters (found 121).
Open

                LOGGER.debug("se crea DetailFieldWithValidations, con las validaciones: {}", validators);

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Wrong lexicographical order for 'com.github.damianwajser.model.details.DetailFieldWithValidations' import. Should be before 'org.slf4j.LoggerFactory'.
Open

import com.github.damianwajser.model.details.DetailFieldWithValidations;

Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

Line is longer than 100 characters (found 132).
Open

        boolean isAuditable = field.getWriteMethod() != null && field.getWriteMethod().isAnnotationPresent(Auditable.class);

Checks for long lines.

Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

There are no issues that match your filters.

Category
Status