ursinn/DeadByDaylightMC

View on GitHub
src/main/java/noahnok/dbdl/files/game/events/MainEvents.java

Summary

Maintainability
F
3 days
Test Coverage

Method blockInteract has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    @EventHandler
    public void blockInteract(PlayerInteractEvent e) {

        DGame game = main.getGameManager().getGamePlayerIsIn(e.getPlayer());
        if (game != null && game.getStatus() == STATUS.INGAME) {
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/game/events/MainEvents.java - About 5 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

Method huntedDies has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    @EventHandler
    public void huntedDies(EntityDamageByEntityEvent e) {
        if (e.getEntity() instanceof Player && e.getDamager() instanceof Firework) {
            if (e.getDamager().getCustomName().equals("DBDL-FIREWORK")) {
                e.setCancelled(true);
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/game/events/MainEvents.java - About 5 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

Method sneakMenu has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

    @EventHandler
    public void sneakMenu(PlayerToggleSneakEvent e) {

        if (!e.isSneaking()) {
            DGame game = main.getGameManager().getGamePlayerIsIn(e.getPlayer());
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/game/events/MainEvents.java - About 5 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

Method canMove has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    @EventHandler
    public void canMove(PlayerMoveEvent e) {
        DPlayer dPlayer = main.getDPlayerManager().getPlayer(e.getPlayer().getUniqueId());
        if (dPlayer == null) {
            return;
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/game/events/MainEvents.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

Method sneakMenu has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @EventHandler
    public void sneakMenu(PlayerToggleSneakEvent e) {

        if (!e.isSneaking()) {
            DGame game = main.getGameManager().getGamePlayerIsIn(e.getPlayer());
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/game/events/MainEvents.java - About 1 hr to fix

Method huntedDies has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @EventHandler
    public void huntedDies(EntityDamageByEntityEvent e) {
        if (e.getEntity() instanceof Player && e.getDamager() instanceof Firework) {
            if (e.getDamager().getCustomName().equals("DBDL-FIREWORK")) {
                e.setCancelled(true);
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/game/events/MainEvents.java - About 1 hr to fix

Method blockInteract has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @EventHandler
    public void blockInteract(PlayerInteractEvent e) {

        DGame game = main.getGameManager().getGamePlayerIsIn(e.getPlayer());
        if (game != null && game.getStatus() == STATUS.INGAME) {
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/game/events/MainEvents.java - About 1 hr to fix

Method canMove has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @EventHandler
    public void canMove(PlayerMoveEvent e) {
        DPlayer dPlayer = main.getDPlayerManager().getPlayer(e.getPlayer().getUniqueId());
        if (dPlayer == null) {
            return;
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/game/events/MainEvents.java - About 1 hr to fix

Avoid deeply nested control flow statements.
Open

                        if (game.getStatus() == STATUS.INGAME) {
                            dPlayer.startSpectating(game);
                        }
Severity: Major
Found in src/main/java/noahnok/dbdl/files/game/events/MainEvents.java - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (!lever.isFinished()) {
                            lever.increment(player);

                            e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR,
                                    TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&',
Severity: Major
Found in src/main/java/noahnok/dbdl/files/game/events/MainEvents.java - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (!gen.isFinished()) {
                            gen.increment(player);
                        }
Severity: Major
Found in src/main/java/noahnok/dbdl/files/game/events/MainEvents.java - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (player.isDead()) {
                            pageItem.addLore("&4&lDead/Escaped");
                        } else {
                            pageItem.addClickAction(p -> {
                                p.closeInventory();
Severity: Major
Found in src/main/java/noahnok/dbdl/files/game/events/MainEvents.java - About 45 mins to fix

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

    public void huntedDies(EntityDamageByEntityEvent 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

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

    public void blockInteract(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

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

    public void canMove(PlayerMoveEvent 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

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

    public void sneakMenu(PlayerToggleSneakEvent 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 (dplayer.getPlayerState().isCrawling()) {

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();
}

This block of commented-out lines of code should be removed.
Open

                        dplayer.setStatus(PlayerStatus.DEAD);

Programmers should not comment out code as it bloats programs and reduces readability.

Unused code should be deleted and can be retrieved from source control history if required.

Merge this if statement with the enclosing one.
Open

                        if (!lever.isFinished()) {

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.getDamager().getCustomName().equals("DBDL-FIREWORK")) {

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.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_BLOCK) {

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 (!damaged.getCurrentGame().isHunter(damaged.getId()) &&

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();
}

TODO found
Open

                //TODO Methods for states here!

TODO found
Open

                        // Only applied if the Hunter has a specific perk //TODO Perks for insta kill

There are no issues that match your filters.

Category
Status