src/main/java/noahnok/dbdl/files/game/MatchMaking.java
Method addToMatchmaking
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Open
public boolean addToMatchmaking(Player p, String playType) {
//Check if there are any available games
if (waitingGames.isEmpty()) {
//Try and create a new game
DGame game = main.getGameManager().createNewGame();
- 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 addPlayerToMatchMakingLoop
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public void addPlayerToMatchMakingLoop(final Player p, final String playType) {
BukkitTask tryMatchMake = new BukkitRunnable() {
public void run() {
if (addToMatchmaking(p, playType)) {
removePlayerFromMatchMakingLoop(p);
- Create a ticketCreate a ticket
Method addToMatchmaking
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public boolean addToMatchmaking(Player p, String playType) {
//Check if there are any available games
if (waitingGames.isEmpty()) {
//Try and create a new game
DGame game = main.getGameManager().createNewGame();
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
Open
return false;
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
Open
return true;
- Create a ticketCreate a ticket
Refactor this method to reduce its Cognitive Complexity from 18 to the 15 allowed. Open
Open
public boolean addToMatchmaking(Player p, String playType) {
- 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
TODO found Open
Open
//Check playtype //TODO swap out set values for gamemode value
- Create a ticketCreate a ticket
- Exclude checks