kai-jacobsen/kontentblocks

View on GitHub

Showing 4,293 of 4,293 total issues

Function getTemplatesforContext has a Cognitive Complexity of 14 (exceeds 5 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

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

    public function get($key, $default = null, $group = null)
    {
        $value = $default;

        $isPrivate = false;
Severity: Minor
Found in core/Common/Data/ValueObject.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 render has a Cognitive Complexity of 14 (exceeds 5 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

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

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

  render: function (index) {
    return this.template({
      model: this.model.toJSON(),
      i18n: _.extend(KB.i18n.Refields.image, KB.i18n.Refields.common)
    });
Severity: Major
Found in js/src/fieldsAPI/definitions/image.js and 1 other location - About 1 hr to fix
js/src/fieldsAPI/definitions/file.js on lines 6..11

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

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

  render: function () {
    return this.template({
      model: this.model.toJSON(),
      i18n: _.extend(KB.i18n.Refields.file, KB.i18n.Refields.common)
    });
Severity: Major
Found in js/src/fieldsAPI/definitions/file.js and 1 other location - About 1 hr to fix
js/src/fieldsAPI/definitions/image.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 70.

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

  initialize: function () {
    // Setup Elements
    this.open = false;
    if (this.model.get('globalModule') === true) {
      this.open = true;
Severity: Minor
Found in js/src/backend/Views/ModuleView.js - About 1 hr to fix

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

      Function MediaWorkflow has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      KB.Utils.MediaWorkflow = function (args) {
        var _frame, options;
      
        var defaults = {
          buttontext: 'Buttontext',
      Severity: Minor
      Found in js/src/common/MediaWorkflow.js - About 1 hr to fix

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

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

          Method filterForPost has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function filterForPost(PostEnvironment $environment)
              {
          
                  $pageTemplate = $environment->getPageTemplate();
                  $postType = $environment->getPostType();
          Severity: Minor
          Found in core/Areas/AreaRegistry.php - About 1 hr to fix

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

                    } else if (this.options.expand === 'touch') {
                      L.DomEvent.addListener(
                        container,
                        L.Browser.touch ? 'touchstart mousedown' : 'mousedown',
                        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 272..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 69.

            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

              createViews: function (views) {
                return _.map(views, function (listItem) {
                  return new ListItem({
                    controller: this.controller,
                    $list: this.$el,
            Severity: Major
            Found in js/src/backend/Views/TemplateEditor/FieldsList.js and 1 other location - About 1 hr to fix
            js/src/backend/Views/TemplateEditor/ViewsList.js on lines 30..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 69.

            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

              createViews: function (views) {
                return _.map(views, function (listItem) {
                  return new ListItem({
                    controller: this.controller,
                    $list: this.$el,
            Severity: Major
            Found in js/src/backend/Views/TemplateEditor/ViewsList.js and 1 other location - About 1 hr to fix
            js/src/backend/Views/TemplateEditor/FieldsList.js on lines 20..28

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

            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

                    L.DomEvent.addListener(
                      input,
                      'blur',
                      function() {
                        if (this.options.collapsed && !this._preventBlurCollapse) {
            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 1455..1465

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

            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

                      } else if (L.Browser.touch && this.options.expand === 'touch') {
                        L.DomEvent.addListener(
                          container,
                          'touchstart mousedown',
                          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 1479..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 69.

            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

                  L.DomEvent.addListener(
                    input,
                    'blur',
                    function() {
                      if (this.options.collapsed && !this._preventBlurCollapse) {
            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 248..258

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

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

            KB.ViewsCollection = function () {
              this.views = {};
              this.lastViewAdded = null;
              this.add = function (id, view) {
                if (!this.views[id]) {
            Severity: Minor
            Found in js/src/shared/ViewsCollection.js - About 1 hr to fix

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

                  protected static function action(Request $request)
                  {
                      $delete = false;
                      $data = $request->request->get('data');
                      $target = filter_var($data['targetPid'], FILTER_SANITIZE_NUMBER_INT);
              Severity: Minor
              Found in core/Ajax/Actions/HandleClipboard.php - About 1 hr to fix

                Avoid excessively long variable names like $wp_registered_sidebars. Keep variable name length under 20.
                Open

                        global $wp_registered_sidebars;

                LongVariable

                Since: 0.2

                Detects when a field, formal or local variable is declared with a long name.

                Example

                class Something {
                    protected $reallyLongIntName = -3; // VIOLATION - Field
                    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                        $otherReallyLongName = -5; // VIOLATION - Local
                        for ($interestingIntIndex = 0; // VIOLATION - For
                             $interestingIntIndex < 10;
                             $interestingIntIndex++ ) {
                        }
                    }
                }

                Source https://phpmd.org/rules/naming.html#longvariable

                Avoid excessively long variable names like $numberOfVisibleFields. Keep variable name length under 20.
                Open

                    protected $numberOfVisibleFields = 0;
                Severity: Minor
                Found in core/Fields/StandardFieldSection.php by phpmd

                LongVariable

                Since: 0.2

                Detects when a field, formal or local variable is declared with a long name.

                Example

                class Something {
                    protected $reallyLongIntName = -3; // VIOLATION - Field
                    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                        $otherReallyLongName = -5; // VIOLATION - Local
                        for ($interestingIntIndex = 0; // VIOLATION - For
                             $interestingIntIndex < 10;
                             $interestingIntIndex++ ) {
                        }
                    }
                }

                Source https://phpmd.org/rules/naming.html#longvariable

                Severity
                Category
                Status
                Source
                Language