soderlind/css-flags

View on GitHub
class-css-flags.php

Summary

Maintainability
B
4 hrs
Test Coverage

Method get_css has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function get_css() {

        $this->timer( 'start' );

        $cachetime = filter_var( apply_filters( 'css_flags_cachetime', 7200 ) , FILTER_VALIDATE_INT, array( 'default' => 7200 ) );
Severity: Major
Found in class-css-flags.php - About 2 hrs to fix

    Function get_css has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        private function get_css() {
    
            $this->timer( 'start' );
    
            $cachetime = filter_var( apply_filters( 'css_flags_cachetime', 7200 ) , FILTER_VALIDATE_INT, array( 'default' => 7200 ) );
    Severity: Minor
    Found in class-css-flags.php - About 1 hr 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

    Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space
    Open

                        $finish = $time;
    Severity: Minor
    Found in class-css-flags.php by phpcodesniffer

    Expected 1 space before close parenthesis; 0 found
    Open

            $version = (isset( $options['version'] )) ? $options['version'] : '0';
    Severity: Minor
    Found in class-css-flags.php by phpcodesniffer

    Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space
    Open

                $json = file_get_contents( esc_url( $data_path . '/data/regions.json' ) );
    Severity: Minor
    Found in class-css-flags.php by phpcodesniffer

    Space found before comma in function call
    Open

                $countries = array_diff( $countries , apply_filters( 'css_flags_exclude', array() ) );
    Severity: Minor
    Found in class-css-flags.php by phpcodesniffer

    Assignments must be the first block of code on a line
    Open

            if ( false === ( $css_flags = get_transient( 'css-flags-all-countries' ) ) ) {
    Severity: Minor
    Found in class-css-flags.php by phpcodesniffer

    Assignments must be the first block of code on a line
    Open

            if ( count( $regions_selected = apply_filters( 'css_flags_regions', array() ) ) > 0 ) { // europe, oceania, africa, asia, northamerica, southamerica, middleeast
    Severity: Minor
    Found in class-css-flags.php by phpcodesniffer

    Expected 1 space after comma in function call; 2 found
    Open

                set_transient( 'css-flags-all-countries', $css_flags,  $cachetime );
    Severity: Minor
    Found in class-css-flags.php by phpcodesniffer

    Space found before comma in function call
    Open

            $cachetime = filter_var( apply_filters( 'css_flags_cachetime', 7200 ) , FILTER_VALIDATE_INT, array( 'default' => 7200 ) );
    Severity: Minor
    Found in class-css-flags.php by phpcodesniffer

    Class file names should be based on the class name with "class-" prepended. Expected class-cssflags.php, but found class-css-flags.php.
    Open

    <?php
    Severity: Minor
    Found in class-css-flags.php by phpcodesniffer

    Expected 1 space after open parenthesis; 0 found
    Open

            $version = (isset( $options['version'] )) ? $options['version'] : '0';
    Severity: Minor
    Found in class-css-flags.php by phpcodesniffer

    Assignments must be the first block of code on a line
    Open

            if ( false === ( $regions = get_transient( 'css-flags-all-regions' ) ) ) {
    Severity: Minor
    Found in class-css-flags.php by phpcodesniffer

    Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space
    Open

                $json = file_get_contents( esc_url( $data_path . '/data/flags.json' ) );
    Severity: Minor
    Found in class-css-flags.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status