kai-jacobsen/kontentblocks

View on GitHub

Showing 4,293 of 4,293 total issues

Function save has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function save($new, $old)
    {
        if (is_array($new) && is_array($old)) {
            $nc = count($new);
            $oc = count($old);
Severity: Minor
Found in core/Fields/Definitions/TextMultiple.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

Function evaluateGroupKey has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function evaluateGroupKey($args, &$key)
    {
        //check for special key syntax like group::key
        if (preg_match("/^(.*?)::/i", $key, $out)) {
            if (is_array($out) && count($out) == 2) {
Severity: Minor
Found in core/Fields/StandardFieldSection.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

Function prepareAttachment has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function prepareAttachment($att)
    {
        $attachment = null;

        if ((is_string($att) && is_numeric($att)) || is_int($att)) {
Severity: Minor
Found in core/Fields/Returnobjects/Utilities/ImageObjectDeprecated.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

Function recalibrate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  recalibrate: function () {
    var winH,
      conH,
      position,
      winDiff;
Severity: Minor
Found in js/src/frontend/Views/EditModalModules.js - About 1 hr to fix

    Function sync has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      sync: function (context) {
        var that = this;
        KB.Events.trigger('field.before.sync', this.model);
    
        var clone = that.toJSON();
    Severity: Minor
    Found in js/src/fields/FieldControlModel.js - About 1 hr to fix

      Function createModule has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        createModule: function (module) {
          var Area, data;
          // check if capability is right for this action
          if (Checks.userCan('create_kontentblocks')) {
          } else {
      Severity: Minor
      Found in js/src/shared/ModuleBrowser/ModuleBrowserController.js - About 1 hr to fix

        Function bindHandlers has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            bindHandlers: function () {
              var handlers, checkCounts;
        
              media.view.MediaFrame.Select.prototype.bindHandlers.apply(this, arguments);
        
        
        Severity: Minor
        Found in js/src/wpMediaExt/KB.media.Gallery.js - About 1 hr to fix

          Function init has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            init: function () {
              var that = this;
              var $body = $('body');
              // init general ui components
              this.initTabs();
          Severity: Minor
          Found in js/src/common/UI.js - About 1 hr to fix

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

                public function prepareFormValue($val)
                {
                    if (is_numeric($val)) {
                        return filter_var($val, FILTER_SANITIZE_NUMBER_INT);
                    } else if (is_string($val)) {
            Severity: Minor
            Found in core/Fields/Definitions/Select.php - About 1 hr to fix

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

                  public function markVisibility(Field $field)
                  {
              
                      $field->setVisibility(true);
                      $postType = $this->entity->context->get('postType');
              Severity: Minor
              Found in core/Fields/PostPanelFieldSection.php - About 1 hr to fix

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

                    public function resize($args = array())
                    {
                        if ($this->isSVG) {
                            $this->src = $this->attachment['url'];
                            return $this;
                Severity: Minor
                Found in core/Fields/Definitions/ReturnObjects/ImageReturn.php - About 1 hr to fix

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

                      private function setupMediaElements()
                      {
                          $images = [];
                          foreach ($this->value['images'] as $k => $attId) {
                              if (is_numeric($attId['id'])) {
                  Severity: Minor
                  Found in core/Fields/Definitions/ReturnObjects/GalleryExtReturn.php - About 1 hr to fix

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

                    Stack.prototype.last = function () {
                      if (this.items.length > 0) {
                        return this.items.pop();
                      }
                      return null;
                    Severity: Major
                    Found in js/src/common/Stack.js and 1 other location - About 1 hr to fix
                    js/src/common/Stack.js on lines 25..30

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

                    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

                    Stack.prototype.first = function () {
                      if (this.items.length > 0) {
                        return this.items.shift();
                      }
                      return null;
                    Severity: Major
                    Found in js/src/common/Stack.js and 1 other location - About 1 hr to fix
                    js/src/common/Stack.js on lines 32..37

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

                    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 render has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      render: function () {
                        // append wrapper element
                        this.ModuleView.$el.append(tplModuleControls({
                          model: this.ModuleView.model.toJSON(),
                          i18n: KB.i18n.jsFrontend
                    Severity: Minor
                    Found in js/src/frontend/Views/ModuleControls/ModuleControls.js - About 1 hr to fix

                      Function geocode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            geocode: function(query, cb, context) {
                              getJSON(
                                this.options.serviceUrl + '/address',
                                {
                                  key: this._key,
                      Severity: Minor
                      Found in js/third-party/leaflet-geocoder.js - About 1 hr to fix

                        Function create has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          create: function (ui) {
                            var Area, data, module;
                            // check if capability is right for this action
                            if (Checks.userCan('create_kontentblocks')) {
                            } else {
                        Severity: Minor
                        Found in js/src/frontend/Views/Sidebar/AreaDetails/ModuleDragItem.js - About 1 hr to fix

                          Function geocode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              geocode: function(query, cb, context) {
                                getJSON(
                                  this.options.serviceUrl + '/address',
                                  {
                                    key: this._key,
                          Severity: Minor
                          Found in js/third-party/leaflet.js - About 1 hr to fix

                            Function initialSetup has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              initialSetup: function () {
                                var that = this;
                                var data = this.model.get('value').images || {};
                            
                                data = _.filter(data, function(d){
                            Severity: Minor
                            Found in js/src/fields/controls/gallery-ext/GalleryExtController.js - About 1 hr to fix

                              Method form has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function form()
                                  {
                                      $masterId = $this->properties->parentObjectId;
                                      $translated = false;
                                      $icl = get_post_meta(get_the_ID(), '_icl_lang_duplicate_of', true);
                                Severity
                                Category
                                Status
                                Source
                                Language