class-css-flags.php
Method get_css
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function get_css() {
$this->timer( 'start' );
$cachetime = filter_var( apply_filters( 'css_flags_cachetime', 7200 ) , FILTER_VALIDATE_INT, array( 'default' => 7200 ) );
Function get_css
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
private function get_css() {
$this->timer( 'start' );
$cachetime = filter_var( apply_filters( 'css_flags_cachetime', 7200 ) , FILTER_VALIDATE_INT, array( 'default' => 7200 ) );
- Read upRead up
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
Open
$finish = $time;
- Exclude checks
Expected 1 space before close parenthesis; 0 found Open
Open
$version = (isset( $options['version'] )) ? $options['version'] : '0';
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space Open
Open
$json = file_get_contents( esc_url( $data_path . '/data/regions.json' ) );
- Exclude checks
Space found before comma in function call Open
Open
$countries = array_diff( $countries , apply_filters( 'css_flags_exclude', array() ) );
- Exclude checks
Assignments must be the first block of code on a line Open
Open
if ( false === ( $css_flags = get_transient( 'css-flags-all-countries' ) ) ) {
- Exclude checks
Assignments must be the first block of code on a line Open
Open
if ( count( $regions_selected = apply_filters( 'css_flags_regions', array() ) ) > 0 ) { // europe, oceania, africa, asia, northamerica, southamerica, middleeast
- Exclude checks
Expected 1 space after comma in function call; 2 found Open
Open
set_transient( 'css-flags-all-countries', $css_flags, $cachetime );
- Exclude checks
Space found before comma in function call Open
Open
$cachetime = filter_var( apply_filters( 'css_flags_cachetime', 7200 ) , FILTER_VALIDATE_INT, array( 'default' => 7200 ) );
- Exclude checks
Class file names should be based on the class name with "class-" prepended. Expected class-cssflags.php, but found class-css-flags.php. Open
Open
<?php
- Exclude checks
Expected 1 space after open parenthesis; 0 found Open
Open
$version = (isset( $options['version'] )) ? $options['version'] : '0';
- Exclude checks
Assignments must be the first block of code on a line Open
Open
if ( false === ( $regions = get_transient( 'css-flags-all-regions' ) ) ) {
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space Open
Open
$json = file_get_contents( esc_url( $data_path . '/data/flags.json' ) );
- Exclude checks