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) {
- Read upRead up
- Create a ticketCreate a ticket
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);
- Read upRead up
- Create a ticketCreate a ticket
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());
- Read upRead up
- Create a ticketCreate a ticket
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;
- Read upRead up
- Create a ticketCreate a ticket
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());
- Create a ticketCreate a ticket
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);
- Create a ticketCreate a ticket
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) {
- Create a ticketCreate a ticket
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;
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (game.getStatus() == STATUS.INGAME) {
dPlayer.startSpectating(game);
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (!lever.isFinished()) {
lever.increment(player);
e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR,
TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&',
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (!gen.isFinished()) {
gen.increment(player);
}
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (player.isDead()) {
pageItem.addLore("&4&lDead/Escaped");
} else {
pageItem.addClickAction(p -> {
p.closeInventory();
- Create a ticketCreate a ticket
Refactor this method to reduce its Cognitive Complexity from 36 to the 15 allowed. Open
public void huntedDies(EntityDamageByEntityEvent e) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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()) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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()) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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")) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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()) &&
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
// Only applied if the Hunter has a specific perk //TODO Perks for insta kill
- Create a ticketCreate a ticket
- Exclude checks