Feavy/pokemon-discord-poc

View on GitHub

Showing 4 of 5 total issues

Method handleRequest has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private void handleRequest(HttpExchange exchange) throws IOException {
        Map<String, String> getParameters = queryToMap(exchange.getRequestURI().getQuery());

        if (!getParameters.containsKey("player")) {
            exchange.sendResponseHeaders(400, 0);

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

        public boolean move(Direction direction) {
            changeDirection(direction);
            Location destination = getLocation().clone().add(direction.getOffset());
    
            if (destination.getCollisionType() == AIR) {
    Severity: Minor
    Found in src/main/java/fr/reminy/pokemon_discord/game/entity/Character.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

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

        @Override
        public void onMessageEdit(MessageEditEvent event) {
            if (event.getMessageAuthor().isEmpty()) {
                return;
            }
    Severity: Minor
    Found in src/main/java/fr/reminy/pokemon_discord/listeners/CommandListener.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

    Method onMessageCreate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        @Override
        public void onMessageCreate(MessageCreateEvent event) {
            List<String> args = new ArrayList<>(Arrays.asList(event.getMessageContent().split("\\s+")));
            for (Command cmd : Commands.map().values()) {
                for (String label : cmd.getLabels()) {
    Severity: Minor
    Found in src/main/java/fr/reminy/pokemon_discord/listeners/CommandListener.java - About 25 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

    Severity
    Category
    Status
    Source
    Language