PressLabs/gitium

View on GitHub

Showing 4,852 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

      The class Git_Wrapper has 20 public methods. Consider refactoring Git_Wrapper to keep number of public methods under 10.
      Open

      class Git_Wrapper {
      
          private $last_error = '';
          private $gitignore  = GITIGNORE;
      
      
      Severity: Minor
      Found in gitium/inc/class-git-wrapper.php by phpmd

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

      The class Git_Wrapper has an overall complexity of 129 which is very high. The configured complexity threshold is 50.
      Open

      class Git_Wrapper {
      
          private $last_error = '';
          private $gitignore  = GITIGNORE;
      
      
      Severity: Minor
      Found in gitium/inc/class-git-wrapper.php by phpmd

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          public function admin_menu() {
              add_menu_page(
                  __( 'Git Configuration', 'gitium' ),
                  'Gitium',
                  GITIUM_MANAGE_OPTIONS_CAPABILITY,
      Severity: Major
      Found in gitium/inc/class-gitium-submenu-configure.php and 1 other location - About 3 hrs to fix
      gitium/inc/class-gitium-submenu-status.php on lines 31..50

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 144.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          public function admin_menu() {
              add_menu_page(
                  __( 'Git Status', 'gitium' ),
                  'Gitium',
                  GITIUM_MANAGE_OPTIONS_CAPABILITY,
      Severity: Major
      Found in gitium/inc/class-gitium-submenu-status.php and 1 other location - About 3 hrs to fix
      gitium/inc/class-gitium-submenu-configure.php on lines 33..52

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 144.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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

            Avoid excessively long variable names like $gitium_submit_merge_push. Keep variable name length under 20.
            Open

                    $gitium_submit_merge_push = filter_input(INPUT_POST, 'GitiumSubmitMergeAndPush', FILTER_SANITIZE_FULL_SPECIAL_CHARS);

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            Avoid excessively long variable names like $generate_new_webhook_key. Keep variable name length under 20.
            Open

            function gitium_get_webhook_key( $generate_new_webhook_key = false ) {
            Severity: Minor
            Found in gitium/functions.php by phpmd

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            Avoid excessively long variable names like $submit_regenerate_pub_key. Keep variable name length under 20.
            Open

                    $submit_regenerate_pub_key = filter_input(INPUT_POST, 'GitiumSubmitRegeneratePublicKey', FILTER_SANITIZE_FULL_SPECIAL_CHARS);

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            Avoid excessively long variable names like $gitium_disconnect_repo. Keep variable name length under 20.
            Open

                    $gitium_disconnect_repo = filter_input(INPUT_POST, 'GitiumSubmitDisconnectRepository', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
            Severity: Minor
            Found in gitium/inc/class-gitium-menu.php by phpmd

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            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

                Severity
                Category
                Status
                Source
                Language