xoopscube/altsys

View on GitHub

Showing 242 of 242 total issues

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

      if ($p_header['mdate'] && $p_header['mtime']) {
          // ----- Extract time
      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
          $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
          $v_seconde = ($p_header['mtime'] & 0x001F)*2;
Severity: Major
Found in xoops_trust_path/libs/altsys/include/Archive_Zip.php and 1 other location - About 4 hrs to fix
xoops_trust_path/libs/altsys/include/Archive_Zip.php on lines 2462..2477

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 182.

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

Method _addFile has 123 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params)
  {
      $v_result=1;

      if ('' == $p_filename) {
Severity: Major
Found in xoops_trust_path/libs/altsys/include/Archive_Zip.php - About 4 hrs to fix

    Function _addFileList has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

      public function _addFileList($p_list, &$p_result_list,
                            $p_add_dir, $p_remove_dir, $p_remove_all_dir,
                            &$p_params)
      {
          $v_result=1;
    Severity: Minor
    Found in xoops_trust_path/libs/altsys/include/Archive_Zip.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 b_altsys_admin_menu_show has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    function b_altsys_admin_menu_show($options)
    {
        global $xoopsUser;
    
        $mydirname = empty($options[0]) ? 'altsys' : $options[0];
    Severity: Minor
    Found in xoops_trust_path/libs/altsys/blocks/block_functions.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

    Method _extractByRule has 122 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      public function _extractByRule(&$p_file_list, &$p_params)
      {
          $v_result=1;
    
          $p_path = $p_params['add_path'];
    Severity: Major
    Found in xoops_trust_path/libs/altsys/include/Archive_Zip.php - About 4 hrs to fix

      File mytplsadmin.php has 361 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * Altsys library (UI-Components)
       * Admin Templates for each module
       * @package    Altsys
      Severity: Minor
      Found in xoops_trust_path/libs/altsys/mytplsadmin.php - About 4 hrs to fix

        Function altsys_onupdate_base has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
        Open

            function altsys_onupdate_base( $module, $mydirname ) {
                // transactions on module update
        
                global $msgs; // TODO :-D
        
        
        Severity: Minor
        Found in xoops_trust_path/libs/altsys/onupdate.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

        Method b_altsys_admin_menu_show has 109 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function b_altsys_admin_menu_show($options)
        {
            global $xoopsUser;
        
            $mydirname = empty($options[0]) ? 'altsys' : $options[0];
        Severity: Major
        Found in xoops_trust_path/libs/altsys/blocks/block_functions.php - About 4 hrs to fix

          Function render has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

              public function render( $diff ) {
                  $xi      = $yi = 1;
                  $block   = false;
                  $context = [];
          
          
          Severity: Minor
          Found in xoops_trust_path/libs/altsys/include/Text_Diff_Renderer.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

          Method _extractFile has 100 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public function _extractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_params)
            {
                $v_result=1;
          
              // ----- Read the file header
          Severity: Major
          Found in xoops_trust_path/libs/altsys/include/Archive_Zip.php - About 4 hrs to fix

            Method triggerEvent has 99 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function triggerEvent($mydirname, $mytrustdirname, $category, $item_id, $event, array $extra_tags = [], array $user_list = [], $omit_user_id = null)
                {
                    $module_handler =& xoops_gethandler('module');
            
                    $module =& $module_handler->getByDirname($mydirname);
            Severity: Major
            Found in xoops_trust_path/libs/altsys/class/D3NotificationHandler.class.php - About 3 hrs to fix

              Method form_edit has 99 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function form_edit( $bid, $mode = 'edit' ) {
                      $bid = (int) $bid;
              
                      //HACK by domifara
                      if ( defined( 'XOOPS_CUBE_LEGACY' ) ) {
              Severity: Major
              Found in xoops_trust_path/libs/altsys/class/MyBlocksAdmin.class.php - About 3 hrs to fix

                Function altsys_onuninstall_base has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                Open

                        function altsys_onuninstall_base($module, $mydirname)
                        {
                            // transations on module uninstall
                
                            global $ret; // TODO :-D
                Severity: Minor
                Found in xoops_trust_path/libs/altsys/onuninstall.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

                Function update_block has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function update_block( $bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $options = [] ) {
                        global $xoopsConfig;
                
                        //HACK by domifara
                        if ( defined( 'XOOPS_CUBE_LEGACY' ) ) {
                Severity: Minor
                Found in xoops_trust_path/libs/altsys/class/MyBlocksAdmin.class.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 _merge has 96 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  public function _merge(&$p_archive_to_add)
                  {
                      $v_result=1;
                
                    // ----- Look if the archive_to_add exists
                Severity: Major
                Found in xoops_trust_path/libs/altsys/include/Archive_Zip.php - About 3 hrs to fix

                  MyBlocksAdmin has 31 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class MyBlocksAdmin {
                      public $db;
                  
                      public $lang;
                  
                  
                  Severity: Minor
                  Found in xoops_trust_path/libs/altsys/class/MyBlocksAdmin.class.php - About 3 hrs to fix

                    Function read has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function read($resource, $mydirname, $mytrustdirname = null, bool $read_once = true)
                        {
                            $d3file = XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/mytrustdirname.php';
                    
                            if (empty($mytrustdirname) && is_file($d3file)) {
                    Severity: Minor
                    Found in xoops_trust_path/libs/altsys/class/D3LanguageManager.class.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

                    Function update has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function update()
                        {
                            $db =& XoopsDatabaseFactory::getDatabaseConnection();
                    
                            // search appropriate column for getting primary_key
                    Severity: Minor
                    Found in xoops_trust_path/libs/altsys/class/d3utilities.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 _add has 84 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      public function _add($p_list, &$p_result_list, &$p_params)
                      {
                          $v_result=1;
                          $v_list_detail = [];
                    
                    
                    Severity: Major
                    Found in xoops_trust_path/libs/altsys/include/Archive_Zip.php - About 3 hrs to fix

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

                                      for ( $j = 0; $j < $opcount; $j ++ ) {
                                          $optval = defined( $options[ $j ]->getVar( 'confop_value' ) ) ? constant( $options[ $j ]->getVar( 'confop_value' ) ) : $options[ $j ]->getVar( 'confop_value' );
                                          $optkey = defined( $options[ $j ]->getVar( 'confop_name' ) ) ? constant( $options[ $j ]->getVar( 'confop_name' ) ) : $options[ $j ]->getVar( 'confop_name' );
                      
                                          $ele->addOption( $optval, $optkey . $addBr );
                      Severity: Major
                      Found in xoops_trust_path/libs/altsys/mypreferences.php and 1 other location - About 3 hrs to fix
                      xoops_trust_path/libs/altsys/mypreferences.php on lines 108..112

                      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 148.

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language