kai-jacobsen/kontentblocks

View on GitHub

Showing 4,293 of 4,293 total issues

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

    public function save( $data, $old )
    {

        if (is_null( $data )) {
            return $old;
Severity: Minor
Found in core/Fields/Definitions/Gallery.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 getAdditionalClasses has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public function getAdditionalClasses(Module $module)
    {
        $classes = array();

        $nextHash = null;
Severity: Minor
Found in core/Frontend/Renderer/AreaRenderer.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

File kb-api.php has 267 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Kontentblocks;

use function foo\func;
Severity: Minor
Found in includes/kb-api.php - About 2 hrs to fix

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

            var result = {
              name: query,
              center: L.latLng(decoded.latitudeCenter, decoded.longitudeCenter),
              bbox: L.latLngBounds(
                L.latLng(decoded.latitudeLo, decoded.longitudeLo),
    Severity: Major
    Found in js/third-party/leaflet.js and 1 other location - About 2 hrs to fix
    js/third-party/leaflet.js on lines 945..952

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

    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

            var result = {
              name: code,
              center: L.latLng(location.lat, location.lng),
              bbox: L.latLngBounds(
                L.latLng(location.lat, location.lng),
    Severity: Major
    Found in js/third-party/leaflet.js and 1 other location - About 2 hrs to fix
    js/third-party/leaflet.js on lines 924..931

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

    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

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

      initImages: function () {
        _.each(this.ids, function (imageId) {
          var image = this.selection.get(imageId);
          if (image){
    
    
    Severity: Major
    Found in js/src/fields/controls/gallery-ext/GalleryExtController.js and 1 other location - About 2 hrs to fix
    js/src/fields/controls/gallery2/Gallery2Controller.js on lines 115..122

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

    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

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

      initImages: function () {
        _.each(this.ids, function (imageId) {
          var image = this.selection.get(imageId);
          if (image){
            this.add(this.selection.get(imageId));
    Severity: Major
    Found in js/src/fields/controls/gallery2/Gallery2Controller.js and 1 other location - About 2 hrs to fix
    js/src/fields/controls/gallery-ext/GalleryExtController.js on lines 123..131

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

    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

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

                  latLngBounds = L.latLngBounds(
                    L.latLng(loc.mapView.topLeft.latitude, loc.mapView.topLeft.longitude),
                    L.latLng(loc.mapView.bottomRight.latitude, loc.mapView.bottomRight.longitude)
                  );
    Severity: Major
    Found in js/third-party/leaflet-geocoder.js and 1 other location - About 2 hrs to fix
    js/third-party/leaflet.js on lines 415..418

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

    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

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

                latLngBounds = L.latLngBounds(
                  L.latLng(loc.mapView.topLeft.latitude, loc.mapView.topLeft.longitude),
                  L.latLng(loc.mapView.bottomRight.latitude, loc.mapView.bottomRight.longitude)
                );
    Severity: Major
    Found in js/third-party/leaflet.js and 1 other location - About 2 hrs to fix
    js/third-party/leaflet-geocoder.js on lines 1296..1299

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

    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 (model.get('type') && model.get('type') === 'option') {
          this.PanelViews.option[model.get('baseId')] = new OptionPanelView({
            model: model,
            $parent: this.$el,
            controller: this
    js/src/frontend/Views/Sidebar/PanelOverview/PanelOverviewController.js on lines 40..46

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

    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 (model.get('type') && model.get('type') === 'static') {
          this.PanelViews.static[model.get('baseId')] = new StaticPanelView({
            model: model,
            $parent: this.$el,
            controller: this
    js/src/frontend/Views/Sidebar/PanelOverview/PanelOverviewController.js on lines 32..38

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

    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

    AbstractEditableFieldReturn has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class AbstractEditableFieldReturn implements InterfaceFieldReturn, InterfaceEditableFieldReturn
    {
    
        /**
         * @var mixed
    Severity: Minor
    Found in core/Fields/Definitions/ReturnObjects/AbstractEditableFieldReturn.php - About 2 hrs to fix

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

        attachField: function (FieldModel) {
          this.attachedFields[FieldModel.id] = FieldModel;
          this.listenTo(FieldModel, 'field.model.dirty', this.addChangedField);
          this.listenTo(FieldModel, 'field.model.clean', this.removeChangedField);
          this.listenTo(FieldModel, 'remove', this.removeAttachedField);
      Severity: Major
      Found in js/src/frontend/Models/ModuleModel.js and 1 other location - About 2 hrs to fix
      js/src/frontend/Models/PanelModel.js on lines 11..16

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

      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 3 locations. Consider refactoring.
      Open

        _createButton: function () {
          var that = this;
          var button = jQuery("<a class='button kb-lc-save'>Save</a>").appendTo(this.createContainer);
          button.on('click', function (e) {
            e.preventDefault();
      Severity: Major
      Found in js/src/extensions/LayoutConfigurations.js and 2 other locations - About 2 hrs to fix
      js/src/extensions/LayoutConfigurations.js on lines 153..161
      js/src/extensions/LayoutConfigurations.js on lines 162..170

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

      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 3 locations. Consider refactoring.
      Open

        _loadButton: function () {
          var that = this;
          var button = jQuery("<a class='button-primary kb-lc-load'>Load</a>").appendTo(this.selectContainer);
          button.on('click', function (e) {
            e.preventDefault();
      Severity: Major
      Found in js/src/extensions/LayoutConfigurations.js and 2 other locations - About 2 hrs to fix
      js/src/extensions/LayoutConfigurations.js on lines 144..152
      js/src/extensions/LayoutConfigurations.js on lines 162..170

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

      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 3 locations. Consider refactoring.
      Open

        _deleteButton: function () {
          var that = this;
          var button = jQuery("<a class='delete-js kb-lc-delete'>delete</a>").appendTo(this.selectContainer);
          button.on('click', function (e) {
            e.preventDefault();
      Severity: Major
      Found in js/src/extensions/LayoutConfigurations.js and 2 other locations - About 2 hrs to fix
      js/src/extensions/LayoutConfigurations.js on lines 144..152
      js/src/extensions/LayoutConfigurations.js on lines 153..161

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

      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

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

        attachField: function (FieldModel) {
          this.attachedFields[FieldModel.id] = FieldModel;
          this.listenTo(FieldModel, 'field.model.dirty', this.addChangedField);
          this.listenTo(FieldModel, 'field.model.clean', this.removeChangedField);
          this.listenTo(FieldModel, 'remove', this.removeAttachedField);
      Severity: Major
      Found in js/src/frontend/Models/PanelModel.js and 1 other location - About 2 hrs to fix
      js/src/frontend/Models/ModuleModel.js on lines 29..34

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

      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 saveModules has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function saveModules($modules)
          {
      
              /** @var \Kontentblocks\Modules\Module $module */
              foreach ($modules as $module) {
      Severity: Minor
      Found in core/Backend/Environment/Save/SavePost.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 upscale has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

                  public function upscale($default, $orig_w, $orig_h, $dest_w, $dest_h, $crop)
                  {
                      if (!$crop) {
                          return null;
                      } // Let the wordpress default function handle this.
      Severity: Minor
      Found in core/Utils/ImageResize.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 compare has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          private function compare($first, $group = null, $groups, $value)
          {
              if (is_null($group)) {
                  $group = [
                      'start' => $first['day'],
      Severity: Minor
      Found in core/Fields/Definitions/ReturnObjects/OpeningTimesReturn.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

      Severity
      Category
      Status
      Source
      Language