kai-jacobsen/kontentblocks

View on GitHub

Showing 4,293 of 4,293 total issues

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

  initialize: function () {
    this.defaults = {
      filter:true
    };
    this.settings = this.model.get('settings') || {};
Severity: Major
Found in js/src/fields/controls/multiselect.js and 1 other location - About 1 hr to fix
js/src/fields/controls/imageselect.js on lines 3..9

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

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

The class AreaProperties has 18 fields. Consider redesigning AreaProperties to keep the number of fields under 15.
Open

class AreaProperties
{

    /**
     * area identifier
Severity: Minor
Found in core/Areas/AreaProperties.php by phpmd

TooManyFields

Since: 0.1

Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

Example

class Person {
   protected $one;
   private $two;
   private $three;
   [... many more fields ...]
}

Source https://phpmd.org/rules/codesize.html#toomanyfields

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

  initialSetup: function () {
    var data, types;
    data = this.model.get('value'); // model equals FieldControlModel, value equals parent obj data for this field key

    types = this.model.get('fields');
Severity: Minor
Found in js/src/fields/controls/flexfields/FlexfieldsController.js - About 1 hr to fix

    Function setupMap has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      setupMap: function () {
        var that = this;
        this.map = L.map(this.uniq).setView([53.551086, 9.993682], 15);
        L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
          attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
    Severity: Minor
    Found in js/src/fields/controls/osm.js - About 1 hr to fix

      Method save has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function save($data, $old)
          {
              if (is_null($data)) {
                  return $old;
              }
      Severity: Minor
      Found in core/Fields/Definitions/GalleryExt.php - About 1 hr to fix

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

              geocode: function(query, cb, context) {
                var params = this.options.geocodingQueryParams;
                if (
                  typeof params.proximity !== 'undefined' &&
                  params.proximity.hasOwnProperty('lat') &&
        Severity: Minor
        Found in js/third-party/leaflet-geocoder.js - About 1 hr to fix

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

              geocode: function(query, cb, context) {
                var params = {
                  SingleLine: query,
                  outFields: 'Addr_Type',
                  forStorage: false,
          Severity: Minor
          Found in js/third-party/leaflet.js - About 1 hr to fix

            Function send has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              send: function (data, callback, scope, options) {
                var pid;
                var addPayload = options || {};
            
                if (data.postId) {
            Severity: Minor
            Found in js/src/common/Ajax.js - About 1 hr to fix

              Function initialize has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  initialize: function () {
                    if (!this.options.cropOptions) {
                      this.options.cropOptions = {};
                    }
                    this.options.cropOptions = _.defaults(this.options.cropOptions, {
              Severity: Minor
              Found in js/src/wpMediaExt/KB.media.Crop.js - About 1 hr to fix

                Function applyClasses has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  applyClasses: function () {
                    var $parent, prev;
                    var $modules = this.model.View.$el.find('.module');
                    $modules.removeClass('first-module last-module repeater');
                    for (var i = 0; i < $modules.length; i++) {
                Severity: Minor
                Found in js/src/frontend/Views/AreaView.js - 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 renderContext has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                function renderContext($context, $postId, $areaSettings = array(), $moduleSettings = array())
                {
                    global $post;
                    $postId = (null === $postId) ? $post->ID : $postId;
                    $Environment = Utilities::getPostEnvironment($postId);
                Severity: Minor
                Found in includes/kb-api.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 setupSettings has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function setupSettings($file, $classname)
                    {
                
                        $args = Module::getDefaultSettings();
                        if (property_exists($classname, 'settings')) {
                Severity: Minor
                Found in core/Modules/ModuleRegistry.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 _keydown has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      _keydown: function(e) {
                        var _this = this,
                          select = function select(dir) {
                            if (_this._selection) {
                              L.DomUtil.removeClass(_this._selection, 'leaflet-control-geocoder-selected');
                Severity: Minor
                Found in js/third-party/leaflet-geocoder.js - About 1 hr to fix

                  Method createGlobalModule has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function createGlobalModule($postId, \WP_Post $post, PostEnvironment $environment)
                      {
                  
                          $value = Utilities::getRequest();
                  
                  
                  Severity: Minor
                  Found in core/Backend/Dynamic/GlobalModulesMenu.php - About 1 hr to fix

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

                      ask: function () {
                        var tplName;
                        Notice.prompt('Template Name', 'Please provide a unique template name', '.twig', function (evt, value) {
                            tplName = value;
                            this.create(tplName);
                    js/src/backend/Views/TemplateEditor/controls/DuplicateControl.js on lines 17..25

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

                    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

                      ask: function () {
                        var tplName;
                        Notice.prompt('Template Name', 'Please provide a unique template name', '.twig', function (evt, value) {
                            tplName = value;
                            this.create(tplName);
                    js/src/backend/Views/TemplateEditor/controls/CreateControl.js on lines 17..25

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

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

                        public static function handleUpload()
                        {
                            header( 'Content-Type: text/html; charset=UTF-8' );
                    
                            if (!defined( 'DOING_AJAX' )) {
                    Severity: Minor
                    Found in core/Fields/Definitions/Plupload.php - About 1 hr to fix

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

                          return !!(!this.model.get('predefined') && !this.model.get('disabled') && !this.model.get('submodule') &&
                            Checks.userCan('delete_kontentblocks'));
                      js/src/backend/Views/ModuleControls/controls/DuplicateControl.js on lines 36..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 63.

                      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 (!this.model.get('predefined') && !this.model.get('disabled') && !this.model.get('submodule') &&
                            Checks.userCan('edit_kontentblocks')) {
                      js/src/backend/Views/ModuleControls/controls/DeleteControl.js on lines 64..65

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

                      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

                            data: {
                              action: 'updateModule',
                              data: that.toJSON().entityData,
                              module: that.toJSON(),
                              editmode: (save) ? 'update' : 'preview',
                      Severity: Major
                      Found in js/src/frontend/Models/ModuleModel.js and 1 other location - About 1 hr to fix
                      js/src/frontend/Models/PanelModel.js on lines 42..48

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

                      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