railpage/railpagecore

View on GitHub
lib/Images/Utility/Tagger.php

Summary

Maintainability
F
3 days
Test Coverage

Function suggestLocos has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
Open

    public static function suggestLocos(Image $imageObject, $skipTagged = null) {
        
        $locolookup = array();
        $locos = array();
Severity: Minor
Found in lib/Images/Utility/Tagger.php - About 1 day 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 suggestLocos has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function suggestLocos(Image $imageObject, $skipTagged = null) {
        
        $locolookup = array();
        $locos = array();
Severity: Major
Found in lib/Images/Utility/Tagger.php - About 3 hrs to fix

    The method suggestLocos() has 146 lines of code. Current threshold is set to 100. Avoid really long methods.
    Open

        public static function suggestLocos(Image $imageObject, $skipTagged = null) {
            
            $locolookup = array();
            $locos = array();
    
    Severity: Minor
    Found in lib/Images/Utility/Tagger.php by phpmd

    The method suggestLocos() has an NPath complexity of 5376. The configured NPath complexity threshold is 200.
    Open

        public static function suggestLocos(Image $imageObject, $skipTagged = null) {
            
            $locolookup = array();
            $locos = array();
    
    Severity: Minor
    Found in lib/Images/Utility/Tagger.php by phpmd

    NPathComplexity

    Since: 0.1

    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

    Example

    class Foo {
        function bar() {
            // lots of complicated code
        }
    }

    Source https://phpmd.org/rules/codesize.html#npathcomplexity

    The method suggestLocos() has a Cyclomatic Complexity of 25. The configured cyclomatic complexity threshold is 10.
    Open

        public static function suggestLocos(Image $imageObject, $skipTagged = null) {
            
            $locolookup = array();
            $locos = array();
    
    Severity: Minor
    Found in lib/Images/Utility/Tagger.php by phpmd

    CyclomaticComplexity

    Since: 0.1

    Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

    Example

    // Cyclomatic Complexity = 11
    class Foo {
    1   public function example() {
    2       if ($a == $b) {
    3           if ($a1 == $b1) {
                    fiddle();
    4           } elseif ($a2 == $b2) {
                    fiddle();
                } else {
                    fiddle();
                }
    5       } elseif ($c == $d) {
    6           while ($c == $d) {
                    fiddle();
                }
    7        } elseif ($e == $f) {
    8           for ($n = 0; $n < $h; $n++) {
                    fiddle();
                }
            } else {
                switch ($z) {
    9               case 1:
                        fiddle();
                        break;
    10              case 2:
                        fiddle();
                        break;
    11              case 3:
                        fiddle();
                        break;
                    default:
                        fiddle();
                        break;
                }
            }
        }
    }

    Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

    The method SuggestEvents() contains an exit expression.
    Open

                die;
    Severity: Minor
    Found in lib/Images/Utility/Tagger.php by phpmd

    ExitExpression

    Since: 0.2

    An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

    Example

    class Foo {
        public function bar($param)  {
            if ($param === 42) {
                exit(23);
            }
        }
    }

    Source https://phpmd.org/rules/design.html#exitexpression

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

                if (preg_match("/(\s)/", $num)) {
                    preg_match("/([a-zA-Z0-9]+)(\s)([a-zA-Z0-9]+)/", $num, $matches);
    
                    if (isset( $matches[3] )) {
                        $prop = sprintf("%s%s", $matches[1], $matches[3]);
    Severity: Major
    Found in lib/Images/Utility/Tagger.php and 1 other location - About 3 hrs to fix
    lib/Images/Utility/Tagger.php on lines 197..206

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

    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

                } elseif (strlen($num) == 5) {
                    preg_match("/([a-zA-Z0-9]{2})([0-9]{3})/", $num, $matches);
    
                    if (isset( $matches[2] )) {
                        $prop = sprintf("%s %s", $matches[1], $matches[2]);
    Severity: Major
    Found in lib/Images/Utility/Tagger.php and 1 other location - About 3 hrs to fix
    lib/Images/Utility/Tagger.php on lines 188..206

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

    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

            $stripdates = array(
                "[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{2,4}",  // 12/05/2015
                "[0-9]{1}\/[0-9]{2}\/[0-9]{2}",        // 1/05/2015
                "[0-9]{4}\/[0-9]{2}\/[0-9]{2}",        // 2015/05/12
                "[0-9]{2}\/[0-9]{4}",                  // 05/2015
    Severity: Major
    Found in lib/Images/Utility/Tagger.php and 1 other location - About 1 hr to fix
    lib/News/Base.php on lines 316..330

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

    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

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

            $params = [
                (new Event)->namespace,
                $imageObject->id
            ];
    Severity: Minor
    Found in lib/Images/Utility/Tagger.php and 1 other location - About 35 mins to fix
    lib/Images/Utility/CollectionUtility.php on lines 80..83

    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

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

            $regexes = array(
                "[a-zA-Z0-9\w+]{4,6}",
                "[0-9\w+]{3,5}",
                "[a-zA-Z0-9\w+]{2}",
                "[a-zA-Z0-9\s\w+]{4,6}"
    Severity: Major
    Found in lib/Images/Utility/Tagger.php and 8 other locations - About 30 mins to fix
    lib/Downloads/Base.php on lines 141..146
    lib/Formatting/BbcodeUtility.php on lines 111..116
    lib/Formatting/MakeClickable.php on lines 256..256
    lib/Forums/Forum.php on lines 294..299
    lib/Gallery/Utility/CreateSizes.php on lines 153..153
    lib/Images/Competition.php on lines 258..258
    lib/Locos/Locomotive.php on lines 634..634
    lib/Locos/Locomotive.php on lines 646..646

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

    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

            $string = preg_replace($stripetc, "", $string); 
    Severity: Minor
    Found in lib/Images/Utility/Tagger.php and 2 other locations - About 30 mins to fix
    lib/Formatting/MakeClickable.php on lines 70..70
    lib/Images/Utility/Tagger.php on lines 103..103

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

    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

            $string = preg_replace($stripdates, "", $string); 
    Severity: Minor
    Found in lib/Images/Utility/Tagger.php and 2 other locations - About 30 mins to fix
    lib/Formatting/MakeClickable.php on lines 70..70
    lib/Images/Utility/Tagger.php on lines 104..104

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

    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

                preg_match_all($regex, $title, $matches['title']);
    Severity: Minor
    Found in lib/Images/Utility/Tagger.php and 1 other location - About 30 mins to fix
    lib/Images/Utility/Tagger.php on lines 142..142

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

    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

                preg_match_all($regex, $desc, $matches['description']);
    Severity: Minor
    Found in lib/Images/Utility/Tagger.php and 1 other location - About 30 mins to fix
    lib/Images/Utility/Tagger.php on lines 141..141

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

    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

        }

    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