soderlind/gtm-multisite-admin

View on GitHub

Showing 5 of 16 total issues

Function gtm_multisite_admin_change_tag has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function gtm_multisite_admin_change_tag() {
        header( 'Content-type: application/json' );
        if ( check_ajax_referer( 'gtm_multisite_admin_security', 'security', false ) ) {
            $site_id   = filter_var( $_POST['site_id'],    FILTER_VALIDATE_INT, array( 'default' => 0 ) );
            $gtm_tag = filter_var( $_POST['gtm_tag'],  FILTER_SANITIZE_STRING, array( 'default' => 'Add ID' ) );
Severity: Minor
Found in gtm-multisite-admin.php - About 3 hrs 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 gtm_multisite_admin_change_tag has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function gtm_multisite_admin_change_tag() {
        header( 'Content-type: application/json' );
        if ( check_ajax_referer( 'gtm_multisite_admin_security', 'security', false ) ) {
            $site_id   = filter_var( $_POST['site_id'],    FILTER_VALIDATE_INT, array( 'default' => 0 ) );
            $gtm_tag = filter_var( $_POST['gtm_tag'],  FILTER_SANITIZE_STRING, array( 'default' => 'Add ID' ) );
Severity: Minor
Found in gtm-multisite-admin.php - About 1 hr to fix

    Function error has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                , error: function(e, x, settings, exception) {
                    // Generic debugging
                    var errorMessage;
                    var statusErrorMap = {
                        '400' : "Server understood request but request content was invalid.",
    Severity: Minor
    Found in js/gtm-multisite-admin.js - About 1 hr to fix

      Method manage_columns has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function manage_columns( $column_name, $site_id ) {
      
              if ( 'gtm-tag' == $column_name ) {
                  echo '<div class="gtm-multisite">';
                  //delete_blog_option( $site_id, 'gtm4wp-options');
      Severity: Minor
      Found in gtm-multisite-admin.php - About 1 hr to fix

        Function manage_columns has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function manage_columns( $column_name, $site_id ) {
        
                if ( 'gtm-tag' == $column_name ) {
                    echo '<div class="gtm-multisite">';
                    //delete_blog_option( $site_id, 'gtm4wp-options');
        Severity: Minor
        Found in gtm-multisite-admin.php - About 35 mins 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

        Severity
        Category
        Status
        Source
        Language