robinp7720/Blue-Stats-Minecraft

View on GitHub

Showing 90 of 90 total issues

Method sum has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function sum($stat) {
        $mysqli = $this->mysql;
        $stmt   = $mysqli->stmt_init();

        $aggregateColumn = "";
Severity: Minor
Found in classes/plugin/pluginStats.php - About 1 hr to fix

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

    public function renderPie () {
        $values = [];
        foreach ($this->labels as $label) {
            array_push($values, $this->data[$label]);
        }
Severity: Minor
Found in classes/chart.class.php and 1 other location - About 40 mins to fix
classes/chart.class.php on lines 55..73

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 93.

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 function renderBar () {
        $values = [];
        foreach ($this->labels as $label) {
            array_push($values, $this->data[$label]);
        }
Severity: Minor
Found in classes/chart.class.php and 1 other location - About 40 mins to fix
classes/chart.class.php on lines 75..93

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 93.

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

Function reCache has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function reCache ($name) {
        if ($this->config->get("enabled") == "true" && !isset($_GET["recache"])) {
            $file_name = md5($name) . '.json';
            if (file_exists($this->cache_dir . $file_name)) {
                $file  = file_get_contents($this->cache_dir . $file_name);
Severity: Minor
Found in classes/cache.class.php - 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

Function set has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function set ($option, $value, $plugin = "this") {
        $value = json_encode($value);
        if ($plugin == "this")
            $plugin = $this->pluginName;
        $mysqli = $this->BlueStatsMYQLI;
Severity: Minor
Found in classes/config.class.php - 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

Avoid too many return statements within this method.
Open

                return $seconds . " seconds";
Severity: Major
Found in functions/utils.func.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return $this->itemName($value);
Severity: Major
Found in classes/formatter.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return $value;
Severity: Major
Found in classes/formatter.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

    return FALSE;
Severity: Major
Found in functions/utils.func.php - About 30 mins to fix

Function number_shorten has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function number_shorten ($number, $precision = 3, $divisors = NULL) {

    // Setup default $divisors if not provided
    if (!isset($divisors)) {
        $divisors = [
Severity: Minor
Found in functions/utils.func.php - 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