kai-jacobsen/kontentblocks

View on GitHub

Showing 4,293 of 4,293 total issues

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

    protected static function action(Request $request)
    {
        $data = wp_unslash($request->request->get('data')); // remove slashes from ajax
        $postEnvironment = Utilities::getPostEnvironment($data['post_ID']);

Severity: Minor
Found in core/Ajax/Actions/Autosave.php - About 1 hr to fix

    Method registerPostType has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function registerPostType()
        {
    
    
            $labels = array(
    Severity: Minor
    Found in core/Backend/Dynamic/DynamicAreas.php - About 1 hr to fix

      Method getFrontendValue has 33 lines of code (exceeds 25 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

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

                function(results) {
                  if (requestCount === this._requestCount) {
                    eventData.results = results;
                    this.fire('finish' + mode, eventData);
                    this._geocodeResult(results, suggest);
        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 380..386

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

        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

                  function(results) {
                    if (requestCount === this._requestCount) {
                      eventData.results = results;
                      this.fire('finish' + mode, eventData);
                      this._geocodeResult(results, suggest);
        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 1589..1595

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

        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 name = this.model.get('baseId') + '[' + this.model.get('index') + ']' + '[' + this.model.get('primeKey') + ']';
        Severity: Major
        Found in js/src/fieldsAPI/definitions/editor.js and 1 other location - About 1 hr to fix
        js/src/fieldsAPI/definitions/baseView.js on lines 24..24

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

        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

              return this.model.get('fieldId') + '[' + this.model.get('arrayKey') + ']' + '[' + this.model.get('fieldkey') + ']';
        Severity: Major
        Found in js/src/fieldsAPI/definitions/baseView.js and 1 other location - About 1 hr to fix
        js/src/fieldsAPI/definitions/editor.js on lines 26..26

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

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

          reposition: function () {
            var elpostop, elposleft, mSettings, submodule, pos, height;
            elpostop = 0;
            elposleft = 0;
            mSettings = this.model.get('settings');
        Severity: Minor
        Found in js/src/frontend/Views/ModuleControls/ModuleControls.js - About 1 hr to fix

          Function _createAlt has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                _createAlt: function(result, index) {
                  var li = L.DomUtil.create('li', ''),
                    a = L.DomUtil.create('a', '', li),
                    icon = this.options.showResultIcons && result.icon ? L.DomUtil.create('img', '', a) : null,
                    text = result.html ? undefined : document.createTextNode(result.name),
          Severity: Minor
          Found in js/third-party/leaflet-geocoder.js - About 1 hr to fix

            Function _createAlt has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                _createAlt: function(result, index) {
                  var li = L.DomUtil.create('li', ''),
                    a = L.DomUtil.create('a', '', li),
                    icon = this.options.showResultIcons && result.icon ? L.DomUtil.create('img', '', a) : null,
                    text = result.html ? undefined : document.createTextNode(result.name),
            Severity: Minor
            Found in js/third-party/leaflet.js - About 1 hr to fix

              Method getTemplatesforContext has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getTemplatesforContext(ModuleContext $context)
                  {
                      $collection = array();
                      $collection += $this->getSingles($this->views);
                      $areaContext = $context->areaContext;
              Severity: Minor
              Found in core/Modules/ModuleViewFilesystem.php - About 1 hr to fix

                Function geocode has 32 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-geocoder.js - About 1 hr to fix

                  Function initDraggable has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    initDraggable: function () {
                      var $source, $target, $sourcecontainer, $targetcontainer;
                      var that = this;
                      this.$('.kbml-slot-ref').draggable({
                        revert: 'invalid',
                  Severity: Minor
                  Found in js/src/frontend/Views/LayoutAreaView.js - About 1 hr to fix

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

                        public static function action(Request $request, $send = true)
                        {
                            global $post;
                    
                            $postdata = self::setupPostData($request);
                    Severity: Minor
                    Found in core/Ajax/Actions/Frontend/UpdateModule.php - About 1 hr to fix

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

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

                        Method setupViews has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function setupViews(Module $module)
                            {
                        
                                if ($this->isChildTheme) {
                                    $childPath = trailingslashit(
                        Severity: Minor
                        Found in core/Modules/ModuleViewFilesystem.php - About 1 hr to fix

                          Method auth has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function auth()
                              {
                          
                                  // if a revision gets restored, a new revision is created but everything from the normal edit screen is missing
                                  if ($this->isRevisionScreen === true) {
                          Severity: Minor
                          Found in core/Backend/Environment/Save/SaveRevision.php - About 1 hr to fix

                            Method registerPostType has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function registerPostType()
                                {
                            
                                    $labels = array(
                                        'name' => _x('Global Module', 'post type general name', 'Kontentblocks'),
                            Severity: Minor
                            Found in core/Backend/Dynamic/GlobalModulesMenu.php - About 1 hr to fix

                              Function metaBoxReorder has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                              Open

                                metaBoxReorder: function (e, o, settings, action) {
                                  if (settings.data) {
                                    var a = settings.data;
                              
                                    if (a && a.split) {
                              Severity: Minor
                              Found in js/src/common/UI.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 auth has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  private function auth()
                                  {
                              
                                      // if a revision gets restored, a new revision is created but everything from the normal edit screen is missing
                                      if ($this->isRevisionScreen === true) {
                              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

                              Severity
                              Category
                              Status
                              Source
                              Language