ursinn/DeadByDaylightMC

View on GitHub

Showing 213 of 213 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

package noahnok.dbdl.files.utils;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Severity: Major
Found in src/main/java/noahnok/dbdl/files/utils/InventoryEvents.java and 1 other location - About 2 hrs to fix
src/main/java/noahnok/dbdl/files/utils/pagenation/PageEvent.java on lines 1..42

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 147.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

package noahnok.dbdl.files.utils.pagenation;

import noahnok.dbdl.files.utils.pagenation.buttons.PageItem;
import noahnok.dbdl.files.utils.pagenation.interfaces.GeneralClick;
import org.bukkit.Material;
src/main/java/noahnok/dbdl/files/utils/InventoryEvents.java on lines 1..46

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 147.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method onCommand has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
        if (!(commandSender instanceof Player)) {
            commandSender.sendMessage(main.prefix + "Only players can use this command!");
            return true;
        }
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/commands/MainCommands.java - About 2 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 showGamemodesPage has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public Inventory showGamemodesPage(final DArena a) {
        main.getArenaManager().setUsableGamemodes(a);
        int rows = ((a.getUsableModes().size() / 9) + 1) * 9;

        if (a.getUsableModes().size() == rows) {
Severity: Major
Found in src/main/java/noahnok/dbdl/files/utils/ArenaManagmentInvs.java - About 2 hrs to fix

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

    public void loadGamemodesFromFile() {
        int count = 0;

        for (String key : main.getGamemodesConfig().getConfig().getConfigurationSection("gamemodes").getKeys(false)) {
            String path = "gamemodes." + key + ".";
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/game/DGamemodeManager.java - About 1 hr to fix

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 editorBlockBreakEntity has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @EventHandler
    public void editorBlockBreakEntity(PlayerInteractAtEntityEvent e) {
        if (!main.getArenaEditor().editing.containsKey(e.getPlayer().getUniqueId())) {
            Shulker shulker;
            try {

Method getRandomArena has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public DArena getRandomArena() {
        List<DArena> tempArenaList = new ArrayList<>();
        for (DArena arena : arenas) {
            boolean hasDefault = false;
            for (DGamemode mode : arena.getUsableModes().keySet()) {
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/game/DArenaManager.java - About 1 hr 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 setUsableGamemodes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public void setUsableGamemodes(DArena a) {
        for (DGamemode mode : a.getUsableModes().keySet()) {
            if (a.getPossibleGeneratorLocations().size() < mode.getMaxgenerators()) {
                a.getUsableModes().put(mode, false);
                continue;
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/game/DArenaManager.java - About 1 hr 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public void announceJoin(Player p) {
        for (DPlayer player : players) {
            Player reciever = main.getServer().getPlayer(player.getId());
            reciever.spigot().sendMessage(ChatMessageType.ACTION_BAR,
                    TextComponent.fromLegacyText(ChatColor.GOLD + p.getName() + ChatColor.GRAY + " joined the game!"));
Severity: Major
Found in src/main/java/noahnok/dbdl/files/game/DGame.java and 1 other location - About 1 hr to fix
src/main/java/noahnok/dbdl/files/game/DGame.java on lines 254..264

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 112.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public void announceLeave(Player p) {
        for (DPlayer player : players) {
            Player reciever = main.getServer().getPlayer(player.getId());
            reciever.spigot().sendMessage(ChatMessageType.ACTION_BAR,
                    TextComponent.fromLegacyText(ChatColor.GOLD + p.getName() + ChatColor.GRAY + " left the game!"));
Severity: Major
Found in src/main/java/noahnok/dbdl/files/game/DGame.java and 1 other location - About 1 hr to fix
src/main/java/noahnok/dbdl/files/game/DGame.java on lines 242..252

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 112.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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 onClick has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    @EventHandler
    public void onClick(InventoryClickEvent e) {
        if (e.getView().getTopInventory().getHolder() instanceof Page) {
            e.setCancelled(true);

Severity: Minor
Found in src/main/java/noahnok/dbdl/files/utils/pagenation/PageEvent.java - About 1 hr 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 onClick has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    @EventHandler
    public void onClick(InventoryClickEvent event) {
        //Check if the inventory is custom
        if (event.getView().getTopInventory().getHolder() instanceof CustomHolder) {
            //Cancel the event
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/utils/InventoryEvents.java - About 1 hr 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 hideArenaBlocks has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private void hideArenaBlocks(final DArena a) {
        for (Location loc : a.getPossibleGeneratorLocations()) {
            removeShulker(loc, a);
        }

Severity: Minor
Found in src/main/java/noahnok/dbdl/files/utils/ArenaEditor.java - About 1 hr to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            } else {
                i = invBuilder.createIcon(itemBuilder.getNewBuilder(Material.WOOL)
                        .setByte((short) 14).build(), ChatColor.GOLD + "✕ " + mode.getId());
                i.addLore(ChatColor.translateAlternateColorCodes('&', "&aClick to &a&lENABLE &a this mode!"));
                i.addLore("");
src/main/java/noahnok/dbdl/files/utils/ArenaManagmentInvs.java on lines 148..159

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 102.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            if (Boolean.TRUE.equals(a.getUsableModes().get(mode))) {
                i = invBuilder.createIcon(itemBuilder.getNewBuilder(Material.WOOL)
                        .setByte((short) 5).build(), ChatColor.GREEN + "✔ " + mode.getId());
                i.addLore(ChatColor.translateAlternateColorCodes('&', "&4Click to &4&lDISABLE &4 this mode!"));
                i.addLore("");
src/main/java/noahnok/dbdl/files/utils/ArenaManagmentInvs.java on lines 159..169

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 102.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method getInventory has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public Inventory getInventory() {
        Inventory inv;

        if (pageSize == -1) {
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/utils/pagenation/Page.java - About 1 hr 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 showArenaBlocks has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private void showArenaBlocks(final DArena a) {
        for (Location loc : a.getPossibleGeneratorLocations()) {
            addShulker(loc, BLUE, Material.FURNACE, a);
        }

Severity: Minor
Found in src/main/java/noahnok/dbdl/files/utils/ArenaEditor.java - About 1 hr 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 getExitGateLocation has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private List<Location> getExitGateLocation(Location loc, String dir) {
        List<Location> locs = new ArrayList<>();
        if (dir.equalsIgnoreCase("EAST")) {
            for (int i = -1; i < 2; i++) {
                for (int y = 0; y < 3; y++) {
Severity: Minor
Found in src/main/java/noahnok/dbdl/files/utils/ArenaEditor.java - About 1 hr 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

Severity
Category
Status
Source
Language