kai-jacobsen/kontentblocks

View on GitHub

Showing 398 of 4,293 total issues

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

            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

                              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

                                Function reverse has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                      reverse: function(location, scale, cb, context) {
                                        getJSON(
                                          this.options.serviceUrl +
                                          encodeURIComponent(location.lng) +
                                          ',' +
                                Severity: Minor
                                Found in js/third-party/leaflet-geocoder.js - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language