busy-web/components

View on GitHub

Showing 21 of 21 total issues

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

export default TextField.extend({
    layout: layout,
    classNameBindings: ['checked'],
    attributeBindings: ['checked', 'group', 'disabled'],

Severity: Major
Found in addon/components/checkbox-input.js and 1 other location - About 2 hrs to fix
addon/components/bc-checkbox-input.js on lines 4..20

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

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

export default TextField.extend({
    layout: layout,

    classNameBindings: ['checked'],
    attributeBindings: ['checked', 'group', 'disabled'],
Severity: Major
Found in addon/components/bc-checkbox-input.js and 1 other location - About 2 hrs to fix
addon/components/checkbox-input.js on lines 8..23

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

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

    checkPosition() {
        const elem = this.$().offsetParent();

        let menuHeightTop = elem.height() - (elem.height() - (this.$().offset().top - elem.offset().top)) - 20; // height of the container minus the the bottom space from the top of the button.
        let menuHeightBot = elem.height() - ((this.$().offset().top + this.$().height()) - elem.offset().top) - 20; // height of the container minus the bottom of the select button.
Severity: Minor
Found in addon/components/bc-select.js - About 2 hrs 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 didRender has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    didRender() {
        this._super();

        if (!get(this, 'firstRender')) {
            set(this, 'firstRender', true);
Severity: Minor
Found in addon/components/bc-tabs.js - About 2 hrs 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 openTab has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    openTab(tab) {
        if (this.$().length > 0) {
            // hide all other tabs
            get(this, 'model').forEach(item => item.hideTab());

Severity: Minor
Found in addon/components/bc-tabs.js - About 2 hrs 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 sortableObject has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export default function sortableObject(meta) {
    // get header if it was provided
    let header = get(meta, 'header');
    if (isNone(header)) {
        header = '';
Severity: Minor
Found in addon/utils/sortable-object.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 typeCast has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function typeCast(value) {
    if (/^[.][\d]+/.test(value)) {
        return typeCast(0 + value);
    }

Severity: Minor
Found in addon/utils/parse.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 buildTabData has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    buildTabData() {
        assert('buildTabData must be called after render', this.$().length > 0);

        let model = [];
        this.$(TAB_CONTENT).children().each((index, el) => {
Severity: Minor
Found in addon/components/bc-tabs.js - About 1 hr to fix

    Function sortableObject has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function sortableObject(meta) {
        // get header if it was provided
        let header = get(meta, 'header');
        if (isNone(header)) {
            header = '';
    Severity: Minor
    Found in addon/utils/sortable-object.js - About 1 hr to fix

      Function renderTemplates has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          renderTemplates: function() {
              const list = this.$();
              if (list && list.find) {
                  const row = list.find('section').children('.content-row').first();
                  if (row.length > 0) {
      Severity: Minor
      Found in addon/components/bc-list.js - About 1 hr to fix

        Function createModelContainer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        function createModelContainer(target, model, metaData) {
            assert('model is required for createModelContainer', !isNone(model) && typeof model === 'object');
            assert('metaData is required for createModelContainer', !isEmpty(metaData) && Array.isArray(metaData));
        
            // create container
        Severity: Minor
        Found in addon/components/bc-sortable-list.js - About 55 mins 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

        Avoid deeply nested control flow statements.
        Open

                                        if (get(oldOpt, key) !== get(option, key)) {
                                            hasChanges = true;
                                        }
        Severity: Major
        Found in addon/components/bc-select-menu.js - About 45 mins to fix

          Function open has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              open() {
                  if (!get(this, 'isDestroyed')) {
                      this.bindEscape();
                      this.bindClick();
          
          
          Severity: Minor
          Found in addon/components/bc-select.js - About 45 mins 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 setListener has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          function setListener(type, namespace, listener, capture=false, passive=false) {
          Severity: Minor
          Found in addon/utils/event.js - About 35 mins to fix

            Function bind has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            export function bind(target, type, namespace, listener, { capture=false, rebind=false, passive=false, once=false }) {
            Severity: Minor
            Found in addon/utils/event.js - About 35 mins to fix

              Function addQueryStringPair has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function addQueryStringPair(params, key, value) {
                  if (/\[.+\]/.test(key)) { // parse type: `key[subkey]=value`
                      let [ normalizeKey, subKey ] = key.split('[');
                      subKey = subKey.split(']').join('');
                      let obj = get(params, normalizeKey) || {};
              Severity: Minor
              Found in addon/utils/parse.js - About 35 mins 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

              Avoid too many return statements within this function.
              Open

                              return val;
              Severity: Major
              Found in addon/utils/parse.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return value;
                Severity: Major
                Found in addon/utils/parse.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return val;
                  Severity: Major
                  Found in addon/utils/parse.js - About 30 mins to fix

                    Function click has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        click(evt) {
                            if (!get(this, 'disabled')) {
                                if (!get(this, 'bubbles')) {
                                    evt.stopPropagation();
                                }
                    Severity: Minor
                    Found in addon/components/md-button.js - About 25 mins 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