Sberned/spring-flow-statemachine

View on GitHub
state-machine-core/src/main/java/ru/sberned/statemachine/state/StateChangedEvent.java

Summary

Maintainability
A
0 mins
Test Coverage

Method equals has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Wontfix

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

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

Avoid too many return statements within this method.
Wontfix

        return info != null ? info.equals(that.info) : that.info == null;

    Make "newState" transient or serializable.
    Open

        private E newState;

    Fields in a Serializable class must themselves be either Serializable or transient even if the class is never explicitly serialized or deserialized. For instance, under load, most J2EE application frameworks flush objects to disk, and an allegedly Serializable object with non-transient, non-serializable data members could cause program crashes, and open the door to attackers. In general a Serializable class is expected to fulfil its contract and not have an unexpected behaviour when an instance is serialized.

    This rule raises an issue on non-Serializable fields, and on collection fields when they are not private (because they could be assigned non-Serializable values externally), and when they are assigned non-Serializable types within the class.

    Noncompliant Code Example

    public class Address {
      //...
    }
    
    public class Person implements Serializable {
      private static final long serialVersionUID = 1905122041950251207L;
    
      private String name;
      private Address address;  // Noncompliant; Address isn't serializable
    }
    

    Compliant Solution

    public class Address implements Serializable {
      private static final long serialVersionUID = 2405172041950251807L;
    }
    
    public class Person implements Serializable {
      private static final long serialVersionUID = 1905122041950251207L;
    
      private String name;
      private Address address;
    }
    

    Exceptions

    The alternative to making all members serializable or transient is to implement special methods which take on the responsibility of properly serializing and de-serializing the object. This rule ignores classes which implement the following methods:

     private void writeObject(java.io.ObjectOutputStream out)
         throws IOException
     private void readObject(java.io.ObjectInputStream in)
         throws IOException, ClassNotFoundException;
    

    See

    Make "ids" transient or serializable.
    Open

        private Collection<ID> ids;

    Fields in a Serializable class must themselves be either Serializable or transient even if the class is never explicitly serialized or deserialized. For instance, under load, most J2EE application frameworks flush objects to disk, and an allegedly Serializable object with non-transient, non-serializable data members could cause program crashes, and open the door to attackers. In general a Serializable class is expected to fulfil its contract and not have an unexpected behaviour when an instance is serialized.

    This rule raises an issue on non-Serializable fields, and on collection fields when they are not private (because they could be assigned non-Serializable values externally), and when they are assigned non-Serializable types within the class.

    Noncompliant Code Example

    public class Address {
      //...
    }
    
    public class Person implements Serializable {
      private static final long serialVersionUID = 1905122041950251207L;
    
      private String name;
      private Address address;  // Noncompliant; Address isn't serializable
    }
    

    Compliant Solution

    public class Address implements Serializable {
      private static final long serialVersionUID = 2405172041950251807L;
    }
    
    public class Person implements Serializable {
      private static final long serialVersionUID = 1905122041950251207L;
    
      private String name;
      private Address address;
    }
    

    Exceptions

    The alternative to making all members serializable or transient is to implement special methods which take on the responsibility of properly serializing and de-serializing the object. This rule ignores classes which implement the following methods:

     private void writeObject(java.io.ObjectOutputStream out)
         throws IOException
     private void readObject(java.io.ObjectInputStream in)
         throws IOException, ClassNotFoundException;
    

    See

    Make "info" transient or serializable.
    Open

        private Object info;

    Fields in a Serializable class must themselves be either Serializable or transient even if the class is never explicitly serialized or deserialized. For instance, under load, most J2EE application frameworks flush objects to disk, and an allegedly Serializable object with non-transient, non-serializable data members could cause program crashes, and open the door to attackers. In general a Serializable class is expected to fulfil its contract and not have an unexpected behaviour when an instance is serialized.

    This rule raises an issue on non-Serializable fields, and on collection fields when they are not private (because they could be assigned non-Serializable values externally), and when they are assigned non-Serializable types within the class.

    Noncompliant Code Example

    public class Address {
      //...
    }
    
    public class Person implements Serializable {
      private static final long serialVersionUID = 1905122041950251207L;
    
      private String name;
      private Address address;  // Noncompliant; Address isn't serializable
    }
    

    Compliant Solution

    public class Address implements Serializable {
      private static final long serialVersionUID = 2405172041950251807L;
    }
    
    public class Person implements Serializable {
      private static final long serialVersionUID = 1905122041950251207L;
    
      private String name;
      private Address address;
    }
    

    Exceptions

    The alternative to making all members serializable or transient is to implement special methods which take on the responsibility of properly serializing and de-serializing the object. This rule ignores classes which implement the following methods:

     private void writeObject(java.io.ObjectOutputStream out)
         throws IOException
     private void readObject(java.io.ObjectInputStream in)
         throws IOException, ClassNotFoundException;
    

    See

    Remove this unused private "setInfo" method.
    Open

        private void setInfo(Object info) {

    private methods that are never executed are dead code: unnecessary, inoperative code that should be removed. Cleaning out dead code decreases the size of the maintained codebase, making it easier to understand the program and preventing bugs from being introduced.

    Note that this rule does not take reflection into account, which means that issues will be raised on private methods that are only accessed using the reflection API.

    Noncompliant Code Example

    public class Foo implements Serializable
    {
      private Foo(){}     //Compliant, private empty constructor intentionally used to prevent any direct instantiation of a class.
      public static void doSomething(){
        Foo foo = new Foo();
        ...
      }
      private void unusedPrivateMethod(){...}
      private void writeObject(ObjectOutputStream s){...}  //Compliant, relates to the java serialization mechanism
      private void readObject(ObjectInputStream in){...}  //Compliant, relates to the java serialization mechanism
    }
    

    Compliant Solution

    public class Foo implements Serializable
    {
      private Foo(){}     //Compliant, private empty constructor intentionally used to prevent any direct instantiation of a class.
      public static void doSomething(){
        Foo foo = new Foo();
        ...
      }
    
      private void writeObject(ObjectOutputStream s){...}  //Compliant, relates to the java serialization mechanism
    
      private void readObject(ObjectInputStream in){...}  //Compliant, relates to the java serialization mechanism
    }
    

    Exceptions

    This rule doesn't raise any issue on annotated methods.

    There are no issues that match your filters.

    Category
    Status