modxcms/revolution

View on GitHub

Showing 7,873 of 7,873 total issues

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

        foreach ($contexts as $context) {
            /** @var modAccessResourceGroup $acl */
            $acl = $this->modx->newObject('modAccessResourceGroup');
            $acl->fromArray(array(
                'context_key' => trim($context),
core/model/modx/processors/security/resourcegroup/create.class.php on lines 93..105
core/model/modx/processors/security/resourcegroup/create.class.php on lines 192..204

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

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

Consider simplifying this complex logical expression.
Open

                    if( ( proxyXHR.statusText != 'abort' || proxyXHR.current ) && data ){
                        // Mark active job
                        _complete = false;

                        // Set current upload file
Severity: Major
Found in manager/assets/fileapi/FileAPI.js - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

            if( navigator.plugins && typeof navigator.plugins['Shockwave Flash'] == 'object' ){
                has    = navigator.plugins['Shockwave Flash'].description && !(mime && mime['application/x-shockwave-flash'] && !mime['application/x-shockwave-flash'].enabledPlugin);
            }
            else {
                try {
    Severity: Major
    Found in manager/assets/fileapi/FileAPI.js - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

              } else if ((tag == "tbody" && (where == beforeend || where == afterbegin)) || 
                         (tag == "tr" && (where == beforebegin || where == afterend))) {
                  node = ieTable(3, tbs, html, tbe);
              } else {
                   node = ieTable(2, ts, html, te);   
      Severity: Major
      Found in setup/assets/js/ext-core-debug.js - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

                                        if (((!xhr.status && !xhr.aborted) || 500 == xhr.status) && (options.retry || 0) < options.uploadRetry) {
                                            options.retry = (options.retry || 0) + 1;
                                            var delay = api.networkDownRetryTimeout;
        
                                            // inform about recoverable problems
        Severity: Major
        Found in manager/assets/fileapi/FileAPI.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

                    if(tag == 'td' && (where == afterbegin || where == beforeend) ||
                       !/td|tr|tbody/i.test(tag) && (where == beforebegin || where == afterend)) { 
                      return;
                  }
          Severity: Major
          Found in setup/assets/js/ext-core-debug.js - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                if ('success' in data.response && data.response.success) {
                  data.record.set('state', Ext.ux.UploadDialog.FileRecord.STATE_FINISHED);
                  data.record.set(
                    'note', data.response.message || data.response.error || this.i18n.note_upload_success
                  );
            Severity: Major
            Found in manager/assets/modext/util/uploaddialog.js - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                      if (this.editable !== false && (!e.isSpecialKey() || e.getKey() === e.BACKSPACE) && this.itemDelimiterKey.indexOf !== e.getKey()  && (!e.hasModifier() || e.shiftKey)) {
                          this.lastKey = e.getKey();
                          this.dqTask.delay(this.queryDelay);
                      }        
              Severity: Major
              Found in manager/assets/modext/util/superboxselect.js - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                        if ((r.overridden == 2 && !def) || (r.overridden != 1 && def) || (!r.overridden && !def)) {
                            m.push({
                                text: _('property_remove')
                                ,scope: this
                                ,handler: this.remove.createDelegate(this,[{
                Severity: Major
                Found in manager/assets/modext/widgets/element/modx.grid.element.properties.js - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                          if (t == 'combo-boolean') {
                              v = (v == '1' || v == 'true' || v == 1 || v == true || v == _('yes') || v == 'yes') ? 1 : 0;
                              fld.setValue(v);
                          }
                  Severity: Major
                  Found in manager/assets/modext/widgets/source/modx.grid.source.properties.js - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                            if (t == 'combo-boolean') {
                                v = (v == '1' || v == 'true' || v == 1 || v == true || v == _('yes') || v == 'yes') ? 1 : 0;
                                fld.setValue(v);
                            }
                    Severity: Major
                    Found in manager/assets/modext/widgets/element/modx.grid.element.properties.js - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                              if (fld.isXType('combo') || fld.isXType('checkbox') || fld.isXType('radio') || fld.isXType('displayfield') || fld.isXType('statictextfield') || fld.isXType('hidden')) {
                                  i = i+1;
                                  fld = this.findFirstTextField(i);
                              }
                      Severity: Major
                      Found in manager/assets/modext/widgets/core/modx.panel.js - About 40 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                                if (this.config.url) {            
                                    this.config.loader = new Ext.tree.TreeLoader({
                                        preloadChildren: false
                                        ,baseAttrs: {
                                            uiProvider:MODx.tree.CheckboxNodeUI
                        Severity: Major
                        Found in manager/assets/modext/widgets/core/modx.tree.checkbox.js - About 40 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                                  if (fld.isXType('combo') || fld.isXType('checkbox') || fld.isXType('radio') || fld.isXType('displayfield') || fld.isXType('statictextfield') || fld.isXType('hidden')) {
                                      i = i+1;
                                      fld = this.findFirstTextField(i);
                                  }
                          Severity: Major
                          Found in manager/assets/modext/widgets/core/modx.window.js - About 40 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                      if(isset($trace[$i]['class'])
                                         && isset($trace[$i]['file'])
                                         && ($trace[$i]['class']=='FirePHP'
                                             || $trace[$i]['class']=='FB')
                                         && (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php'
                            Severity: Major
                            Found in manager/min/lib/FirePHP.php - About 40 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                      if(isset($trace[$i]['class'])
                                         && isset($trace[$i]['file'])
                                         && ($trace[$i]['class']=='FirePHP'
                                             || $trace[$i]['class']=='FB')
                                         && (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php'
                              Severity: Major
                              Found in manager/min/lib/FirePHP.php - About 40 mins to fix

                                Consider simplifying this complex logical expression.
                                Open

                                        if ($target=='FILE' && $this->getCacheManager()) {
                                            $filename = isset($targetOptions['filename']) ? $targetOptions['filename'] : 'error.log';
                                            $filepath = isset($targetOptions['filepath']) ? $targetOptions['filepath'] : $this->getCachePath() . xPDOCacheManager::LOG_DIR;
                                            $this->cacheManager->writeFile($filepath . $filename, $content, 'a');
                                        } elseif ($target=='ARRAY' && isset($targetOptions['var']) && is_array($targetOptions['var'])) {
                                Severity: Major
                                Found in core/xpdo/xpdo.class.php - About 40 mins to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                          if (!($conn instanceof xPDOConnection) || ($mutable !== null && (($mutable == true && !$conn->isMutable()) || ($mutable == false && $conn->isMutable())))) {
                                              if (!empty($this->_connections)) {
                                                  shuffle($this->_connections);
                                                  $conn = reset($this->_connections);
                                                  while ($conn) {
                                  Severity: Major
                                  Found in core/xpdo/xpdo.class.php - About 40 mins to fix

                                    Consider simplifying this complex logical expression.
                                    Open

                                            if (isset ($meta['index']) && $meta['index'] == 'pk' && !is_array($pk) && $pktype == 'integer' && isset ($meta['generated']) && $meta['generated'] == 'native') {
                                                $extra= ' IDENTITY PRIMARY KEY';
                                                $null= '';
                                            }
                                    Severity: Major
                                    Found in core/xpdo/om/sqlsrv/xpdomanager.class.php - About 40 mins to fix

                                      Consider simplifying this complex logical expression.
                                      Open

                                              if (isset($meta['index']) && $meta['index'] == 'pk' && !is_array($pk) && $pktype == 'integer' && isset ($meta['generated']) && $meta['generated'] == 'native') {
                                                  $extra= ' AUTO_INCREMENT';
                                              }
                                      Severity: Major
                                      Found in core/xpdo/om/mysql/xpdomanager.class.php - About 40 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language