PressLabs/gitium

View on GitHub

Showing 29 of 4,852 total issues

File class-git-wrapper.php has 522 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*  Copyright 2014-2016 Presslabs SRL <ping@presslabs.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License, version 2, as
Severity: Major
Found in gitium/inc/class-git-wrapper.php - About 1 day to fix

    Git_Wrapper has 43 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Git_Wrapper {
    
        private $last_error = '';
        private $gitignore  = GITIGNORE;
    
    
    Severity: Minor
    Found in gitium/inc/class-git-wrapper.php - About 5 hrs to fix

      Function gitium_upgrader_post_install has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

      function gitium_upgrader_post_install( $res, $hook_extra, $result ) {
          _gitium_make_ssh_git_file_exe();
      
          $action = null;
          $type   = null;
      Severity: Minor
      Found in gitium/gitium.php - About 4 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 _gitium_module_by_path has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      function _gitium_module_by_path( $path ) {
          $versions = gitium_get_versions();
      
          // default values
          $module   = array(
      Severity: Minor
      Found in gitium/functions.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

      File functions.php has 294 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /*  Copyright 2014-2016 Presslabs SRL <ping@presslabs.com>
      
          This program is free software; you can redistribute it and/or modify
          it under the terms of the GNU General Public License, version 2, as
      Severity: Minor
      Found in gitium/functions.php - About 3 hrs to fix

        Method gitium_upgrader_post_install has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function gitium_upgrader_post_install( $res, $hook_extra, $result ) {
            _gitium_make_ssh_git_file_exe();
        
            $action = null;
            $type   = null;
        Severity: Major
        Found in gitium/gitium.php - About 2 hrs to fix

          File gitium.php has 269 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /**
           * Plugin Name: Gitium
           * Version: 1.0.6
           * Author: Presslabs
          Severity: Minor
          Found in gitium/gitium.php - About 2 hrs to fix

            Function add_menu_bubble has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public function add_menu_bubble() {
                    global $menu;
            
                    if ( ! _gitium_is_status_working()  ) {
                        foreach ( $menu as $key => $value  ) {
            Severity: Minor
            Found in gitium/inc/class-gitium-menu-bubble.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 local_status has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                function local_status() {
                    list( $return, $response ) = $this->_call( 'status', '-s', '-b', '-u' );
                    if ( 0 !== $return ) {
                        return array( '', array() );
                    }
            Severity: Minor
            Found in gitium/inc/class-git-wrapper.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

            Method _gitium_module_by_path has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function _gitium_module_by_path( $path ) {
                $versions = gitium_get_versions();
            
                // default values
                $module   = array(
            Severity: Minor
            Found in gitium/functions.php - About 1 hr to fix

              Method gitium_update_versions has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function gitium_update_versions() {
                  $new_versions = [];
              
                  // get all themes from WP
                  $all_themes = wp_get_themes( array( 'allowed' => true ) );
              Severity: Minor
              Found in gitium/gitium.php - About 1 hr to fix

                Function get_local_changes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    function get_local_changes() {
                        list( $return, $response ) = $this->_call( 'status', '--porcelain'  );
                
                        if ( 0 !== $return ) {
                            return array();
                Severity: Minor
                Found in gitium/inc/class-git-wrapper.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 page has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function page() {
                        ?>
                        <div class="wrap">
                        <h2><?php printf( __( 'Last %s commits', 'gitium' ), GITIUM_LAST_COMMITS ); ?></h2>
                        <table class="wp-list-table widefat plugins">
                Severity: Minor
                Found in gitium/inc/class-gitium-submenu-commits.php - About 1 hr to fix

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

                      protected function _call(...$args) {
                          $args     = join( ' ', array_map( 'escapeshellarg', $args ) );
                          $return   = -1;
                          $response = array();
                          $env      = $this->get_env();
                  Severity: Minor
                  Found in gitium/inc/class-git-wrapper.php - About 1 hr to fix

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

                        private function setup_step_2() {
                            $git = $this->git; ?>
                            <div class="wrap">
                            <h2><?php _e( 'Configuration step 2', 'gitium' ); ?></h2>
                            <p><?php _e( 'If you need help to set this up, please click on the "Help" button from the top right corner of this screen.' ); ?></p>
                    Severity: Minor
                    Found in gitium/inc/class-gitium-submenu-configure.php - About 1 hr to fix

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

                          function merge_with_accept_mine(...$commits) {
                              do_action( 'gitium_before_merge_with_accept_mine' );
                      
                              if ( 1 == count($commits) && is_array( $commits[0] ) ) {
                                  $commits = $commits[0];
                      Severity: Minor
                      Found in gitium/inc/class-git-wrapper.php - About 1 hr to fix

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

                            private function show_git_changes_table_rows( $changes = '' ) {
                                ?>
                                <script type="application/javascript">
                                function add_path_and_submit( elem ) {
                                    var container = document.getElementById( 'form_status' );
                        Severity: Minor
                        Found in gitium/inc/class-gitium-submenu-status.php - About 1 hr to fix

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

                          function gitium_update_versions() {
                              $new_versions = [];
                          
                              // get all themes from WP
                              $all_themes = wp_get_themes( array( 'allowed' => true ) );
                          Severity: Minor
                          Found in gitium/gitium.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 status has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              function status( $local_only = false ) {
                                  list( $branch_status, $new_response ) = $this->local_status();
                          
                                  if ( $local_only ) { return array( $branch_status, $new_response ); }
                          
                          
                          Severity: Minor
                          Found in gitium/inc/class-git-wrapper.php - About 45 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 cherry_pick has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private function cherry_pick( $commits ) {
                                  foreach ( $commits as $commit ) {
                                      if ( empty( $commit ) ) { return false; }
                          
                                      list( $return, $response ) = $this->_call( 'cherry-pick', $commit );
                          Severity: Minor
                          Found in gitium/inc/class-git-wrapper.php - About 45 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