railpage/railpagecore

View on GitHub
lib/Locos/Utility/LocosUtility.php

Summary

Maintainability
A
2 hrs
Test Coverage

Avoid using undefined variables such as '$return' which will lead to PHP notices.
Open

        $return['count'] = 0;
Severity: Minor
Found in lib/Locos/Utility/LocosUtility.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$return' which will lead to PHP notices.
Open

        $return['stat'] = "ok"; 
Severity: Minor
Found in lib/Locos/Utility/LocosUtility.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$return' which will lead to PHP notices.
Open

        return $return;
Severity: Minor
Found in lib/Locos/Utility/LocosUtility.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$return' which will lead to PHP notices.
Open

            $return['count']++;
Severity: Minor
Found in lib/Locos/Utility/LocosUtility.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$return' which will lead to PHP notices.
Open

            $return[$key][$row['id']] = $row;
Severity: Minor
Found in lib/Locos/Utility/LocosUtility.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

The method addAsset uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $data['meta'] = $meta;
        }
Severity: Minor
Found in lib/Locos/Utility/LocosUtility.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid unused parameters such as '$type'.
Open

    public static function CreateUrl($type, $parts) {
Severity: Minor
Found in lib/Locos/Utility/LocosUtility.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

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

        if (!is_array($data)) {
            throw new Exception("Cannot add asset - \$data must be an array"); 
            return false;
        }
Severity: Minor
Found in lib/Locos/Utility/LocosUtility.php and 1 other location - About 1 hr to fix
lib/Jobs/Jobs.php on lines 60..64

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

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 3 locations. Consider refactoring.
Open

        $url = strtolower(implode("/", $base)); 
Severity: Major
Found in lib/Locos/Utility/LocosUtility.php and 2 other locations - About 40 mins to fix
lib/Locations/Locations.php on lines 472..472
lib/Locos/Locomotive.php on lines 1528..1528

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

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 15 locations. Consider refactoring.
Open

            $data['meta'] = ContentUtility::FixJSONEncode_UTF8($data['meta']); 
Severity: Major
Found in lib/Locos/Utility/LocosUtility.php and 14 other locations - About 35 mins to fix
lib/Formatting/MultimediaUtility.php on lines 263..263
lib/Images/Competition.php on lines 351..351
lib/Images/Exif.php on lines 145..145
lib/Images/Exif.php on lines 146..146
lib/Images/Exif.php on lines 147..147
lib/Images/ImageFactory.php on lines 229..229
lib/Images/Utility/Finder.php on lines 706..706
lib/Images/Utility/Finder.php on lines 735..735
lib/News/Topic.php on lines 233..233
lib/News/Topic.php on lines 290..290
lib/News/Topic.php on lines 292..292
lib/Newsletters/Weekly.php on lines 412..412
lib/Newsletters/Weekly.php on lines 414..414
lib/Users/Timeline.php on lines 177..177

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

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 closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }

There must be one blank line after the last USE statement; 2 found;
Open

use Zend_Db_Expr;

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }

There are no issues that match your filters.

Category
Status