Passed
Push — master ( 563beb...b73ca5 )
by Roannel Fernández
05:09
created

com.github.netkorp.telegram.framework.commands.interfaces.Command   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A descriptionKey() 0 7 3
1
package com.github.netkorp.telegram.framework.commands.interfaces;
0 ignored issues
show
Code Smell introduced by
It is a best practice to supply a copyright/licence header in your code. Your organisation probably has a template for that.
Loading history...
2
3
/**
4
 * Contains the logic of a command to be executed by the users.
5
 */
6
public interface Command {
0 ignored issues
show
Coding Style introduced by
Move this left curly brace to the beginning of next line of code.
Loading history...
7
8
    /**
9
     * Returns the command's description key, used to retrieve the help message.
10
     *
11
     * @return the command's description key.
12
     */
13
    default String descriptionKey() {
0 ignored issues
show
Coding Style introduced by
Make this line start at column 3.
Loading history...
Coding Style introduced by
Move this left curly brace to the beginning of next line of code.
Loading history...
14
        String className = this.getClass().getSimpleName().toLowerCase();
0 ignored issues
show
introduced by
Define the locale to be used in this String operation.
Loading history...
Coding Style introduced by
Make this line start at column 5.
Loading history...
15
        if (!"command".equals(className) && className.endsWith("command")) {
0 ignored issues
show
Coding Style introduced by
Move this left curly brace to the beginning of next line of code.
Loading history...
16
            className = className.substring(0, className.length() - 7);
0 ignored issues
show
Coding Style introduced by
Make this line start at column 7.
Loading history...
Comprehensibility introduced by
Consider assigning this magic number 7 to a constant.

Using constants for hard-coded numbers is a best practice. A constant’s name can explain the rationale behind this magic number. It is also easier to find if you ever need to change it.

Loading history...
17
        }
18
19
        return "commands.description." + className;
20
    }
21
}
22