ursinn/MinecraftServer

View on GitHub
src/main/java/com/github/joshj1091/mcserver/MCServer.java

Summary

Maintainability
A
0 mins
Test Coverage

Refactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.
Open

    public MCServer() throws IOException {

Cognitive Complexity is a measure of how hard the control flow of a method is to understand. Methods with high Cognitive Complexity will be difficult to maintain.

See

Remove this assignment of "instance".
Open

        instance = this;

Assigning a value to a static field in a constructor could cause unreliable behavior at runtime since it will change the value for all instances of the class.

Instead remove the field's static modifier, or initialize it statically.

Noncompliant Code Example

public class Person {
  static Date dateOfBirth;
  static int expectedFingers;

  public Person(date birthday) {
    dateOfBirth = birthday;  // Noncompliant; now everyone has this birthday
    expectedFingers = 10;  // Noncompliant
  }
}

Compliant Solution

public class Person {
  Date dateOfBirth;
  static int expectedFingers = 10;

  public Person(date birthday) {
    dateOfBirth = birthday;
  }
}

There are no issues that match your filters.

Category
Status