kai-jacobsen/kontentblocks

View on GitHub

Showing 4,293 of 4,293 total issues

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

    private function preparedPageTemplates($data)
    {
        $collect = array();
        $postData = (isset($data['pageTemplates'])) ? ($data['pageTemplates']) : array();
        $pageTemplates = Utilities::getPageTemplates();
Severity: Major
Found in core/Backend/Dynamic/DynamicAreas.php and 1 other location - About 1 hr to fix
core/Backend/Dynamic/DynamicAreas.php on lines 194..210

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

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

    private function preparedPostTypes($data)
    {
        $collect = array();
        $postData = (isset($data['postTypes'])) ? ($data['postTypes']) : array();
        $postTypes = Utilities::getPostTypes();
Severity: Major
Found in core/Backend/Dynamic/DynamicAreas.php and 1 other location - About 1 hr to fix
core/Backend/Dynamic/DynamicAreas.php on lines 220..236

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

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

  factorNewItem: function (data, obj) {
    var uid = obj['_meta'].uid || null;
    var title = obj['_meta'].title || null;
    var type = obj['_meta'].type;
    var status = obj['_meta'].status || 'visible';
Severity: Minor
Found in js/src/fields/controls/flexfields/FlexFieldsFactory.js - About 1 hr to fix

    Function _keydown has 40 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.js - About 1 hr to fix

      Method getCoreActions has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function getCoreActions()
          {
              return apply_filters(
                  'kb.ajax.core.actions',
                  array(
      Severity: Minor
      Found in core/Ajax/AjaxCallbackHandler.php - About 1 hr to fix

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

          attachModule: function (ModuleModel) {
            this.attachedModules[ModuleModel.cid] = ModuleModel; // add module
            this.listenTo(ModuleModel, 'change:area', this.removeModule); // add listener
            this.trigger('module.attached', ModuleModel);
          },
        Severity: Major
        Found in js/src/backend/Views/SystemAreaView.js and 1 other location - About 1 hr to fix
        js/src/backend/Views/AreaView.js on lines 65..69

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

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

            public function addField($type, $key, $args = array())
            {
        
                if (is_string($key) && empty($key)) {
                    return $this;
        Severity: Minor
        Found in core/Fields/StandardFieldSection.php - About 1 hr to fix

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

            attachModule: function (ModuleModel) {
              this.attachedModules[ModuleModel.cid] = ModuleModel; // add module
              this.listenTo(ModuleModel, 'change:area', this.removeModule); // add listener
              this.trigger('module.attached', ModuleModel);
            },
          Severity: Major
          Found in js/src/backend/Views/AreaView.js and 1 other location - About 1 hr to fix
          js/src/backend/Views/SystemAreaView.js on lines 21..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 67.

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

            getFieldData: function (type, moduleId, key, arrayKey) {
              var typeData;
              if (this._typeExists(type)) {
                typeData = KB.payload.fieldData[type];
                // no data for module id
          Severity: Minor
          Found in js/src/common/Payload.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 addByFile has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public function addByFile($file)
              {
                  include_once $file;
                  $classname = str_replace('.php', '', basename($file));
                  $modelArg = '';
          Severity: Minor
          Found in core/Panels/PanelRegistry.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 saveModules has a Cognitive Complexity of 13 (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/SaveRevision.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 getFrontendValue has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getFrontendValue($salt = null)
              {
          
                  if (!is_null($this->userValue)) {
                      return $this->userValue;
          Severity: Minor
          Found in core/Fields/Field.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 Config has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var Config = (function ($) {
            var config = KB.appData.config || {};
            return {
              /**
               * General getter
          Severity: Minor
          Found in js/src/common/Config.js - About 1 hr to fix

            Method connect has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function connect($classname, $args)
                {
                    $setting = $args['settings']['connect'];
                    $postTypes = get_post_types_by_support('kontentblocks');
                    if (empty($setting)) {
            Severity: Minor
            Found in core/Areas/AreaRegistry.php - About 1 hr to fix

              Function moduleUpdated has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                moduleUpdated: function (res, b, c, save, notice) {
                  var that = this;
              
                  that.model.trigger('modal.serialize.before');
              
              
              Severity: Minor
              Found in js/src/frontend/Views/EditModalModules.js - About 1 hr to fix

                Method action has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected static function action(Request $request)
                    {
                        $module = wp_unslash($request->request->get('module'));
                        $tplName = wp_unslash($request->request->get('filename', ''));
                        $environment = Utilities::getPostEnvironment($module['postId']);
                Severity: Minor
                Found in core/Ajax/Actions/CreateModuleViewTemplate.php - About 1 hr to fix

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

                      public function render($echo)
                      {
                          $concater = ConcatContent::getInstance();
                          if (!$this->validate()) {
                              return false;
                  Severity: Minor
                  Found in core/Frontend/Renderer/AreaRenderer.php - About 1 hr to fix

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

                              if (this.options.expand === 'click') {
                                L.DomEvent.addListener(
                                  container,
                                  'click',
                                  function(e) {
                    Severity: Major
                    Found in js/third-party/leaflet-geocoder.js and 1 other location - About 1 hr to fix
                    js/third-party/leaflet.js on lines 1468..1494

                    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

                    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/imageselect.js and 1 other location - About 1 hr to fix
                    js/src/fields/controls/multiselect.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

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

                            if (this.options.expand === 'click') {
                              L.DomEvent.addListener(
                                container,
                                'click',
                                function(e) {
                    Severity: Major
                    Found in js/third-party/leaflet.js and 1 other location - About 1 hr to fix
                    js/third-party/leaflet-geocoder.js on lines 261..287

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language