danielwippermann/resol-vbus

View on GitHub
src/base-configuration-optimizer.js

Summary

Maintainability
F
5 days
Test Coverage

Function completeConfiguration has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

    async completeConfiguration(...configs) {
        const _this = this;

        const adjustableValues = _this._getAdjustableValues();

Severity: Minor
Found in src/base-configuration-optimizer.js - About 7 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 _getAdjustableValues has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    _getAdjustableValues() {
        const data = this.constructor.configurationData;

        const typeById = (data.types || []).reduce((memo, type) => {
            memo [type.id] = type;
Severity: Minor
Found in src/base-configuration-optimizer.js - About 6 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

File base-configuration-optimizer.js has 434 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*! resol-vbus | Copyright (c) 2013-present, Daniel Wippermann | MIT license */

const ConfigurationOptimizer = require('./configuration-optimizer');
const {
    isNumber,
Severity: Minor
Found in src/base-configuration-optimizer.js - About 6 hrs to fix

    Function completeConfiguration has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async completeConfiguration(...configs) {
            const _this = this;
    
            const adjustableValues = _this._getAdjustableValues();
    
    
    Severity: Major
    Found in src/base-configuration-optimizer.js - About 3 hrs to fix

      Function _getAdjustableValues has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _getAdjustableValues() {
              const data = this.constructor.configurationData;
      
              const typeById = (data.types || []).reduce((memo, type) => {
                  memo [type.id] = type;
      Severity: Major
      Found in src/base-configuration-optimizer.js - About 2 hrs to fix

        ValuesWrapper has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class ValuesWrapper {
        
            constructor(pattern, values) {
                this.pattern = pattern;
                this.values = values;
        Severity: Minor
        Found in src/base-configuration-optimizer.js - About 2 hrs to fix

          Function _optimizeConfiguration has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _optimizeConfiguration(config, adjustableValues) {
                  const configValueById = config.reduce((memo, configValue) => {
                      memo [configValue.valueId] = configValue;
                      return memo;
                  }, {});
          Severity: Minor
          Found in src/base-configuration-optimizer.js - About 1 hr to fix

            Function _check has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                _check(action, checker, options) {
                    const _this = this;
            
                    options = {
                        includeUndefined: true,
            Severity: Minor
            Found in src/base-configuration-optimizer.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 _buildConfiguration has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                _buildConfiguration(oldConfig) {
                    if (oldConfig === undefined) {
                        oldConfig = [];
                    }
            
            
            Severity: Minor
            Found in src/base-configuration-optimizer.js - About 1 hr to fix

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

                      const adjustableValues = data.values.reduce((memo, value) => {
                          if (adjustableValueIds [value.id]) {
                              const valueTextById = {};
                              const addValueText = (valueText, index) => {
                                  if (valueText.id && !hasOwnProperty(valueTextById, valueText.id)) {
              Severity: Minor
              Found in src/base-configuration-optimizer.js - About 1 hr to fix

                Function _check has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    _check(action, checker, options) {
                        const _this = this;
                
                        options = {
                            includeUndefined: true,
                Severity: Minor
                Found in src/base-configuration-optimizer.js - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if (numericValue.charAt(0) === '#') {
                                              const valueTextId = numericValue.slice(1);
                                              const valueText = refValue.valueTextById [valueTextId];
                                              if (valueText !== undefined) {
                                                  numericValue = valueText;
                  Severity: Major
                  Found in src/base-configuration-optimizer.js - About 45 mins to fix

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

                        $(pattern, values) {
                            if (values === undefined) {
                                ({ values } = this);
                            }
                    
                    
                    Severity: Minor
                    Found in src/base-configuration-optimizer.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

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

                            newConfig.sort((l, r) => {
                                let result = r.priority - l.priority;
                                if (result === 0) {
                                    result = l.valueIndex - r.valueIndex;
                                }
                    Severity: Major
                    Found in src/base-configuration-optimizer.js and 1 other location - About 1 hr to fix
                    tools/configuration-importer/index.js on lines 223..229

                    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 6 locations. Consider refactoring.
                    Open

                        eql(refValue, callback) {
                            return this._check(callback, (value, valueInfo) => {
                                const normalizedRefValue = this._normalizeValue(refValue, valueInfo);
                                return (value === normalizedRefValue);
                            });
                    Severity: Major
                    Found in src/base-configuration-optimizer.js and 5 other locations - About 50 mins to fix
                    src/base-configuration-optimizer.js on lines 71..76
                    src/base-configuration-optimizer.js on lines 78..83
                    src/base-configuration-optimizer.js on lines 85..90
                    src/base-configuration-optimizer.js on lines 92..97
                    src/base-configuration-optimizer.js on lines 99..104

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

                    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 6 locations. Consider refactoring.
                    Open

                        lt(refValue, callback) {
                            return this._check(callback, (value, valueInfo) => {
                                const normalizedRefValue = this._normalizeValue(refValue, valueInfo);
                                return (value < normalizedRefValue);
                            });
                    Severity: Major
                    Found in src/base-configuration-optimizer.js and 5 other locations - About 50 mins to fix
                    src/base-configuration-optimizer.js on lines 64..69
                    src/base-configuration-optimizer.js on lines 71..76
                    src/base-configuration-optimizer.js on lines 85..90
                    src/base-configuration-optimizer.js on lines 92..97
                    src/base-configuration-optimizer.js on lines 99..104

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

                    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 6 locations. Consider refactoring.
                    Open

                        gt(refValue, callback) {
                            return this._check(callback, (value, valueInfo) => {
                                const normalizedRefValue = this._normalizeValue(refValue, valueInfo);
                                return (value > normalizedRefValue);
                            });
                    Severity: Major
                    Found in src/base-configuration-optimizer.js and 5 other locations - About 50 mins to fix
                    src/base-configuration-optimizer.js on lines 64..69
                    src/base-configuration-optimizer.js on lines 71..76
                    src/base-configuration-optimizer.js on lines 78..83
                    src/base-configuration-optimizer.js on lines 85..90
                    src/base-configuration-optimizer.js on lines 99..104

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

                    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 6 locations. Consider refactoring.
                    Open

                        lte(refValue, callback) {
                            return this._check(callback, (value, valueInfo) => {
                                const normalizedRefValue = this._normalizeValue(refValue, valueInfo);
                                return (value <= normalizedRefValue);
                            });
                    Severity: Major
                    Found in src/base-configuration-optimizer.js and 5 other locations - About 50 mins to fix
                    src/base-configuration-optimizer.js on lines 64..69
                    src/base-configuration-optimizer.js on lines 71..76
                    src/base-configuration-optimizer.js on lines 78..83
                    src/base-configuration-optimizer.js on lines 92..97
                    src/base-configuration-optimizer.js on lines 99..104

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

                    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 6 locations. Consider refactoring.
                    Open

                        gte(refValue, callback) {
                            return this._check(callback, (value, valueInfo) => {
                                const normalizedRefValue = this._normalizeValue(refValue, valueInfo);
                                return (value >= normalizedRefValue);
                            });
                    Severity: Major
                    Found in src/base-configuration-optimizer.js and 5 other locations - About 50 mins to fix
                    src/base-configuration-optimizer.js on lines 64..69
                    src/base-configuration-optimizer.js on lines 71..76
                    src/base-configuration-optimizer.js on lines 78..83
                    src/base-configuration-optimizer.js on lines 85..90
                    src/base-configuration-optimizer.js on lines 92..97

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

                    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 6 locations. Consider refactoring.
                    Open

                        notEql(refValue, callback) {
                            return this._check(callback, (value, valueInfo) => {
                                const normalizedRefValue = this._normalizeValue(refValue, valueInfo);
                                return (value !== normalizedRefValue);
                            });
                    Severity: Major
                    Found in src/base-configuration-optimizer.js and 5 other locations - About 50 mins to fix
                    src/base-configuration-optimizer.js on lines 64..69
                    src/base-configuration-optimizer.js on lines 78..83
                    src/base-configuration-optimizer.js on lines 85..90
                    src/base-configuration-optimizer.js on lines 92..97
                    src/base-configuration-optimizer.js on lines 99..104

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

                    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

                    There are no issues that match your filters.

                    Category
                    Status