isotopsweden/wp-cargo

View on GitHub

Showing 16 of 2,470 total issues

Function run_queue has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function run_queue() {
        $database = $this->cargo->make( 'database' );
        $pusher   = $this->cargo->make( 'pusher' );

        foreach ( $database->all() as $item ) {
Severity: Minor
Found in src/runner/class-basic.php - About 2 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

Function prepare_meta has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    protected function prepare_meta( $object_id, $meta ) {
        if ( ! is_array( $meta ) ) {
            return [];
        }

Severity: Minor
Found in src/content/abstract-content.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

Method create_item has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function create_item( $menu, $parent_id, $post ) {
        $item = [];
        $type = get_post_meta( $post->ID, '_menu_item_type', true );

        switch ( $type ) {
Severity: Minor
Found in src/content/class-menus.php - About 1 hr to fix

    Method prepare_meta has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function prepare_meta( $object_id, $meta ) {
            if ( ! is_array( $meta ) ) {
                return [];
            }
    
    
    Severity: Minor
    Found in src/content/abstract-content.php - About 1 hr to fix

      Method send has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function send( $data ) {
              $options = $this->cargo->config( 'pusher.http', ['url' => ''] );
              $options = is_array( $options ) ? $options : ['url' => ''];
      
              $json = $this->to_json( $data );
      Severity: Minor
      Found in src/pusher/class-http.php - About 1 hr to fix

        Function config has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public function config( string $key, $default = null, array $source = [] ) {
                if ( isset( $source[$key] ) ) {
                    return $source[$key];
                }
        
        
        Severity: Minor
        Found in src/class-cargo.php - About 55 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

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

        function push_post_or_term( $id, $post = null ) {
            // Check if there was a multisite switch before.
            if ( is_multisite() && ms_is_switched() ) {
                return false;
            }
        Severity: Minor
        Found in src/admin/post.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

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

            public function __construct() {
                $menus  = wp_get_nav_menus();
                $result = [];
        
                // Get registered nav manues and nav menu locations.
        Severity: Minor
        Found in src/content/class-menus.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

        Avoid too many return statements within this method.
        Open

            return $res;
        Severity: Major
        Found in src/admin/post.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              return $res;
          Severity: Major
          Found in src/admin/post.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return false;
            Severity: Major
            Found in src/pusher/class-http.php - About 30 mins to fix

              Function __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function __construct( $post ) {
                      // Bail if empty.
                      if ( empty( $post ) ) {
                          return;
                      }
              Severity: Minor
              Found in src/content/class-post.php - About 25 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

              Function get_terms has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function get_terms( $post ) {
                      $result     = [];
                      $taxonomies = get_object_taxonomies( $post );
              
                      foreach ( $taxonomies as $taxonomy ) {
              Severity: Minor
              Found in src/content/class-post.php - About 25 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

              Function push_delete_post_or_term has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function push_delete_post_or_term( $id, $taxonomy = '' ) {
                  // Check if there was a multisite switch before.
                  if ( is_multisite() && ms_is_switched() ) {
                      return false;
                  }
              Severity: Minor
              Found in src/admin/post.php - About 25 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

              Function modify_preview_link has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function modify_preview_link( $link, $post ) {
                  if ( empty( $_POST ) ) {
                      return $link;
                  }
              
              
              Severity: Minor
              Found in src/admin/post.php - About 25 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

              Function push_trash_post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function push_trash_post( $new_status, $old_status, $post ) {
                  // Check if there was a multisite switch before.
                  if ( is_multisite() && ms_is_switched() ) {
                      return false;
                  }
              Severity: Minor
              Found in src/admin/post.php - About 25 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