soderlind/gtm-multisite-admin

View on GitHub
gtm-multisite-admin.php

Summary

Maintainability
B
6 hrs
Test Coverage

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

    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

      Array closer not aligned correctly; expected 8 space(s) but found 12
      Open

                  )
      Severity: Minor
      Found in gtm-multisite-admin.php by phpcodesniffer

      Array item not aligned correctly; expected 12 spaces but found 16
      Open

                      'nonce' => wp_create_nonce( 'gtm_multisite_admin_security' ),
      Severity: Minor
      Found in gtm-multisite-admin.php by phpcodesniffer

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

                  $site_id   = filter_var( $_POST['site_id'],    FILTER_VALIDATE_INT, array( 'default' => 0 ) );
      Severity: Minor
      Found in gtm-multisite-admin.php by phpcodesniffer

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

                              $gtm_tag_options = get_blog_option( $site_id, 'gtm4wp-options' );
      Severity: Minor
      Found in gtm-multisite-admin.php by phpcodesniffer

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

                  $gtm_tag = filter_var( $_POST['gtm_tag'],  FILTER_SANITIZE_STRING, array( 'default' => 'Add ID' ) );
      Severity: Minor
      Found in gtm-multisite-admin.php by phpcodesniffer

      Array item not aligned correctly; expected 12 spaces but found 16
      Open

                      'ajaxurl' => $ajaxurl,
      Severity: Minor
      Found in gtm-multisite-admin.php by phpcodesniffer

      Array double arrow not aligned correctly; expected 3 space(s) between "'nonce'" and double arrow, but found 1.
      Open

                      'nonce' => wp_create_nonce( 'gtm_multisite_admin_security' ),
      Severity: Minor
      Found in gtm-multisite-admin.php by phpcodesniffer

      Class file names should be based on the class name with "class-" prepended. Expected class-gtm-multisite-admin.php, but found gtm-multisite-admin.php.
      Open

      <?php
      Severity: Minor
      Found in gtm-multisite-admin.php by phpcodesniffer

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

                  $site_id   = filter_var( $_POST['site_id'],    FILTER_VALIDATE_INT, array( 'default' => 0 ) );
      Severity: Minor
      Found in gtm-multisite-admin.php by phpcodesniffer

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

                  $gtm_options = (array) get_blog_option( $site_id, 'gtm4wp-options' );
      Severity: Minor
      Found in gtm-multisite-admin.php by phpcodesniffer

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

                      $response['message']     = 'something went wrong ...';
      Severity: Minor
      Found in gtm-multisite-admin.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status