xoopscube/altsys

View on GitHub

Showing 242 of 242 total issues

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

Function _readEndCentralDir has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  public function _readEndCentralDir(&$p_central_dir)
  {
      $v_result=1;

    // ----- Go to the end of the zip file
Severity: Minor
Found in xoops_trust_path/libs/altsys/include/Archive_Zip.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 _readEndCentralDir has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public function _readEndCentralDir(&$p_central_dir)
  {
      $v_result=1;

    // ----- Go to the end of the zip file
Severity: Major
Found in xoops_trust_path/libs/altsys/include/Archive_Zip.php - About 3 hrs to fix

    Method altsys_oninstall_base has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            function altsys_oninstall_base( $module, $mydirname ) {
                // transactions on module install
    
                global $ret; // TODO :-D
    
    
    Severity: Major
    Found in xoops_trust_path/libs/altsys/oninstall.php - About 3 hrs to fix

      Function draw_repost_form has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

              public function draw_repost_form(string $area = '' ) {
                  // Notify which file is broken
      
                  if ( headers_sent() ) {
                      restore_error_handler();
      Severity: Minor
      Found in xoops_trust_path/libs/altsys/include/gtickets.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 diff has 75 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function diff( $from_lines, $to_lines ) {
              $n_from = count( $from_lines );
              $n_to   = count( $to_lines );
      
              $this->xchanged = $this->ychanged = [];
      Severity: Major
      Found in xoops_trust_path/libs/altsys/include/Text_Diff.php - About 3 hrs to fix

        Function triggerEvent has a Cognitive Complexity of 21 (exceeds 5 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: Minor
        Found in xoops_trust_path/libs/altsys/class/D3NotificationHandler.class.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 _shiftBoundaries has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function _shiftBoundaries( $lines, &$changed, $other_changed ) {
                $i = 0;
                $j = 0;
        
                assert( count( $lines ) == count( $changed ) );
        Severity: Major
        Found in xoops_trust_path/libs/altsys/include/Text_Diff.php - About 2 hrs to fix

          Method _diag has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function _diag( $xoff, $xlim, $yoff, $ylim, $nchunks ) {
                  $flip = false;
          
                  if ( $xlim - $xoff > $ylim - $yoff ) {
                      /* Things seems faster (I'm not sure I understand why) when the
          Severity: Major
          Found in xoops_trust_path/libs/altsys/include/Text_Diff.php - About 2 hrs to fix

            Method renderCell4BlockPosition has 61 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function renderCell4BlockPosition( $block_data ) {
                    $bid     = (int) $block_data['bid'];
                    $side    = (int) $block_data['side'];
                    $visible = (int) $block_data['visible'];
            
            
            Severity: Major
            Found in xoops_trust_path/libs/altsys/class/MyBlocksAdmin.class.php - About 2 hrs to fix

              Function _tool_PathInclusion has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                public function _tool_PathInclusion($p_dir, $p_path)
                {
                    $v_result = 1;
              
                  // ----- Explode dir and path by directory separator
              Severity: Minor
              Found in xoops_trust_path/libs/altsys/include/Archive_Zip.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 altsys_admin_in_theme_in_last has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function altsys_admin_in_theme_in_last( $contents = null ) {
                  global $xoops_admin_contents, $xoopsConfig, $xoopsModule, $xoopsUser, $xoopsUserIsAdmin, $xoopsLogger, $altsysModuleConfig, $altsysModuleId;
              
                  if ( ! isset( $contents ) ) {
                      while ( ob_get_level() ) {
              Severity: Major
              Found in xoops_trust_path/libs/altsys/include/admin_in_theme_functions.php - About 2 hrs to fix

                Method list_blocks has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function list_blocks() {
                        global $xoopsGTicket;
                
                        // main query
                        $sql       = 'SELECT * FROM ' . $this->db->prefix( 'newblocks' ) . " WHERE mid='$this->target_mid' ORDER BY visible DESC,side,weight";
                Severity: Major
                Found in xoops_trust_path/libs/altsys/class/MyBlocksAdmin.class.php - About 2 hrs to fix

                  Method render has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function render() {
                          global $xoopsGTicket;
                  
                          // load all child ids for javascript codes
                          foreach ( array_keys( $this->_itemTree ) as $item_id ) {
                  Severity: Major
                  Found in xoops_trust_path/libs/altsys/include/mygrouppermform.php - About 2 hrs to fix

                    Method check has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            public function check(bool $post = true, string $area = '', bool $allow_repost = true ) {
                                global $xoopsModule;
                    
                                $this->_errors = [];
                    
                    
                    Severity: Major
                    Found in xoops_trust_path/libs/altsys/include/gtickets.php - About 2 hrs to fix

                      Method altsys_onupdate_base has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function altsys_onupdate_base( $module, $mydirname ) {
                              // transactions on module update
                      
                              global $msgs; // TODO :-D
                      
                      
                      Severity: Major
                      Found in xoops_trust_path/libs/altsys/onupdate.php - About 2 hrs to fix

                        Method read has 50 lines of code (exceeds 25 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 2 hrs to fix

                          Method update_block has 50 lines of code (exceeds 25 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 2 hrs to fix

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

                                                if ( ! $tplfile_handler->insert( $tplfile ) ) {
                                                    $msgs[] = '<span style="color:#ff0000;">ERROR: Could not insert template <b>' . htmlspecialchars( $mydirname . '_' . $file ) . '</b> to the database.</span>';
                                                } else {
                                                    $tplid  = $tplfile->getVar( 'tpl_id' );
                                                    $msgs[] = 'Template <b>' . htmlspecialchars( $mydirname . '_' . $file ) . '</b> added to the database. (ID: <b>' . $tplid . '</b>)';
                            Severity: Major
                            Found in xoops_trust_path/libs/altsys/onupdate.php and 1 other location - About 1 hr to fix
                            xoops_trust_path/libs/altsys/oninstall.php on lines 109..116

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

                            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

                                                    if ( ! $tplfile_handler->insert( $tplfile ) ) {
                                                        $ret[] = '<span style="color:#ff0000;">ERROR: Could not insert template <b>' . htmlspecialchars( $mydirname . '_' . $file ) . '</b> to the database.</span><br>';
                                                    } else {
                                                        $tplid = $tplfile->getVar( 'tpl_id' );
                                                        $ret[] = 'Template <b>' . htmlspecialchars( $mydirname . '_' . $file ) . '</b> added to the database. (ID: <b>' . $tplid . '</b>)<br>';
                            Severity: Major
                            Found in xoops_trust_path/libs/altsys/oninstall.php and 1 other location - About 1 hr to fix
                            xoops_trust_path/libs/altsys/onupdate.php on lines 71..79

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

                            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