railpage/railpagecore

View on GitHub
lib/Formatting/BbcodeUtility.php

Summary

Maintainability
B
4 hrs
Test Coverage

Method preProcessBBCodeUIDs has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function preProcessBBCodeUIDs($string) {
        
        $format_search    = array(
            '#\[url=(.*?)\](.*?)\[/url\] by \[url=(.*?)\](.*?)\[/url\], on Flickr#i',
            "@\[b:([a-zA-Z0-9]+)]@i", 
Severity: Minor
Found in lib/Formatting/BbcodeUtility.php - About 1 hr to fix

    The method Process has a boolean flag argument $doBbcode, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public static function Process($string, $doBbcode = true) {
    Severity: Minor
    Found in lib/Formatting/BbcodeUtility.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

    Avoid unused local variables such as '$emoticonConfig'.
    Open

            $emoticonConfig = [ 
    Severity: Minor
    Found in lib/Formatting/BbcodeUtility.php by phpmd

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

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

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

            $format_replace    = array(
                '<a href="$1" class="rp-drawflickr">$1</a>',
                "[b]",
                "[quote=", 
                "[/quote]",
    Severity: Major
    Found in lib/Formatting/BbcodeUtility.php and 5 other locations - About 55 mins to fix
    lib/Events/Month.php on lines 151..151
    lib/Formatting/BbcodeUtility.php on lines 89..97
    lib/Formatting/MultimediaUtility.php on lines 179..187
    lib/Locos/Liveries/Livery.php on lines 297..297
    lib/Locos/Locomotive.php on lines 400..400

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

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

            $format_search    = array(
                '#\[url=(.*?)\](.*?)\[/url\] by \[url=(.*?)\](.*?)\[/url\], on Flickr#i',
                "@\[b:([a-zA-Z0-9]+)]@i", 
                "@\[quote:([a-zA-Z0-9]+)=@i", 
                "@\[/quote:([a-zA-Z0-9]+)\]@i",
    Severity: Major
    Found in lib/Formatting/BbcodeUtility.php and 5 other locations - About 55 mins to fix
    lib/Events/Month.php on lines 151..151
    lib/Formatting/BbcodeUtility.php on lines 99..107
    lib/Formatting/MultimediaUtility.php on lines 179..187
    lib/Locos/Liveries/Livery.php on lines 297..297
    lib/Locos/Locomotive.php on lines 400..400

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

    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

            $uc_search = array(
                "[URL",
                "[/URL]",
                "[IMG",
                "[/IMG]"
    Severity: Major
    Found in lib/Formatting/BbcodeUtility.php and 8 other locations - About 30 mins to fix
    lib/Downloads/Base.php on lines 141..146
    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/Images/Utility/Tagger.php on lines 131..136
    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 8 locations. Consider refactoring.
    Open

            $string = preg_replace($format_search, $format_replace, $string);
    Severity: Major
    Found in lib/Formatting/BbcodeUtility.php and 7 other locations - About 30 mins to fix
    lib/Formatting/BbcodeUtility.php on lines 124..124
    lib/Formatting/MultimediaUtility.php on lines 191..191
    lib/Images/Exif.php on lines 230..230
    lib/Links/Links.php on lines 305..305
    lib/News/Base.php on lines 347..347
    lib/News/Utility/ArticleUtility.php on lines 97..97
    lib/AppCore.php on lines 700..700

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

            $string = str_replace($uc_search, $uc_replace, $string);
    Severity: Major
    Found in lib/Formatting/BbcodeUtility.php and 7 other locations - About 30 mins to fix
    lib/Formatting/BbcodeUtility.php on lines 109..109
    lib/Formatting/MultimediaUtility.php on lines 191..191
    lib/Images/Exif.php on lines 230..230
    lib/Links/Links.php on lines 305..305
    lib/News/Base.php on lines 347..347
    lib/News/Utility/ArticleUtility.php on lines 97..97
    lib/AppCore.php on lines 700..700

    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

        }

    Spaces must be used for alignment; tabs are not allowed
    Open

            $format_replace    = array(

    Spaces must be used for alignment; tabs are not allowed
    Open

            $format_search    = array(

    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