ursinn/DeadByDaylightMC

View on GitHub
src/main/java/noahnok/dbdl/files/signs/SignEvents.java

Summary

Maintainability
B
4 hrs
Test Coverage

Method signInteract has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    @EventHandler
    public void signInteract(PlayerInteractEvent e) {
        if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) || e.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
            if (e.getClickedBlock().getType().equals(Material.SIGN) ||
                    e.getClickedBlock().getType().equals(Material.WALL_SIGN)) {
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/signs/SignEvents.java - About 3 hrs to fix

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 deeply nested control flow statements.
Open

                        if (main.getSignManager().getSign(e.getClickedBlock()).getGame() != null) {
                            if (main.getSignManager().getSign(e.getClickedBlock()).getGame().equals(
                                    main.getGameManager().getGamePlayerIsIn(e.getPlayer()))) {
                                e.getPlayer().sendMessage("You are already in a game!");
                                return;
Severity: Major
Found in src/main/java/noahnok/dbdl/files/signs/SignEvents.java - About 45 mins to fix

Method signBreakEvent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    @EventHandler
    public void signBreakEvent(BlockBreakEvent e) {
        if (e.getBlock().getType().equals(Material.SIGN) || e.getBlock().getType().equals(Material.WALL_SIGN)) {
            if (((Sign) e.getBlock().getState()).getLine(0).equals(signLine)) {
                if (e.getPlayer().hasPermission("dbdl.sign.break")) {
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/signs/SignEvents.java - About 35 mins to fix

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

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

    public void signInteract(PlayerInteractEvent e) {

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

Merge this if statement with the enclosing one.
Open

                if (main.getSignManager().getSign(e.getClickedBlock()) != null) {

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if (file != null) {
  if (file.isFile() || file.isDirectory()) {
    /* ... */
  }
}

Compliant Solution

if (file != null && isFileOrDirectory(file)) {
  /* ... */
}

private static boolean isFileOrDirectory(File file) {
  return file.isFile() || file.isDirectory();
}

Merge this if statement with the enclosing one.
Open

            if (((Sign) e.getBlock().getState()).getLine(0).equals(signLine)) {

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if (file != null) {
  if (file.isFile() || file.isDirectory()) {
    /* ... */
  }
}

Compliant Solution

if (file != null && isFileOrDirectory(file)) {
  /* ... */
}

private static boolean isFileOrDirectory(File file) {
  return file.isFile() || file.isDirectory();
}

Merge this if statement with the enclosing one.
Open

            if (e.getClickedBlock().getType().equals(Material.SIGN) ||

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if (file != null) {
  if (file.isFile() || file.isDirectory()) {
    /* ... */
  }
}

Compliant Solution

if (file != null && isFileOrDirectory(file)) {
  /* ... */
}

private static boolean isFileOrDirectory(File file) {
  return file.isFile() || file.isDirectory();
}

Merge this if statement with the enclosing one.
Open

            if (e.getLine(1).equalsIgnoreCase("join")) {

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if (file != null) {
  if (file.isFile() || file.isDirectory()) {
    /* ... */
  }
}

Compliant Solution

if (file != null && isFileOrDirectory(file)) {
  /* ... */
}

private static boolean isFileOrDirectory(File file) {
  return file.isFile() || file.isDirectory();
}

Merge this if statement with the enclosing one.
Open

                        if (main.getSignManager().getSign(e.getClickedBlock()).getGame() != null) {

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if (file != null) {
  if (file.isFile() || file.isDirectory()) {
    /* ... */
  }
}

Compliant Solution

if (file != null && isFileOrDirectory(file)) {
  /* ... */
}

private static boolean isFileOrDirectory(File file) {
  return file.isFile() || file.isDirectory();
}

There are no issues that match your filters.

Category
Status