creative-connections/Bodylight.js-Components

View on GitHub
src_aurelia-bodylight-plugin/src/elements/value.js

Summary

Maintainability
D
2 days
Test Coverage

Function bind has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

  bind() {
    //register throttled update function    
    if (typeof this.throttle === 'string') this.throttle = parseInt(this.throttle, 10);
    if (typeof this.tofixed === 'string') this.tofixed = parseInt(this.tofixed, 10);
    if (typeof this.dataevent === 'string') this.dataevent = this.dataevent === 'true';
Severity: Minor
Found in src_aurelia-bodylight-plugin/src/elements/value.js - About 4 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 updateValue has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  updateValue(rawvalue) {
    if (rawvalue.toPrecision) {  
      if ((this.tofixed !== null) && (this.tofixed !== undefined) && (this.tofixed>=0)) {
        //probably will have toFixed function
        if (this.operation) this.value = this.operation[0](rawvalue).toFixed(this.tofixed); // * this.numerator / this.denominator + this.addconst;
Severity: Minor
Found in src_aurelia-bodylight-plugin/src/elements/value.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 bind has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  bind() {
    //register throttled update function    
    if (typeof this.throttle === 'string') this.throttle = parseInt(this.throttle, 10);
    if (typeof this.tofixed === 'string') this.tofixed = parseInt(this.tofixed, 10);
    if (typeof this.dataevent === 'string') this.dataevent = this.dataevent === 'true';
Severity: Minor
Found in src_aurelia-bodylight-plugin/src/elements/value.js - About 1 hr to fix

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

      attached() {
        //listening to custom event fmidata
        //listening to custom event fmidata and fmireset
        const fromel = document.getElementById(this.fromid);
        if (fromel) {
    Severity: Minor
    Found in src_aurelia-bodylight-plugin/src/elements/value.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

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

        if (this.tohash) {
          if (this.previousvalue != this.value) {  //change only if it differs from previous value
            this.previousvalue = this.value;
            if (this.value.length>0 && this.value[0] === '#') window.location.hash = this.value;
            else window.location.hash = '#'+this.value; //add hash if it is missing in the string value
    Severity: Major
    Found in src_aurelia-bodylight-plugin/src/elements/value.js and 1 other location - About 4 hrs to fix
    src_aurelia-bodylight-plugin/src/elements/fb-get-state.js on lines 18..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 124.

    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

        this.handleFMIAttached = e => {
          const fromel = document.getElementById(this.fromid);
          if (fromel) {
            fromel.addEventListener('fmidata', this.handleValueChange);
          } else {
    Severity: Major
    Found in src_aurelia-bodylight-plugin/src/elements/value.js and 1 other location - About 2 hrs to fix
    src_aurelia-bodylight-plugin/src/elements/value-store.js on lines 24..31

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

    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

          if ((this.tofixed !== null) && (this.tofixed !== undefined) && (this.tofixed>=0)) {
            //probably will have toFixed function
            if (this.operation) this.value = this.operation[0](rawvalue).toFixed(this.tofixed); // * this.numerator / this.denominator + this.addconst;
            else this.value = rawvalue.toFixed(this.tofixed);
          } else {    
    Severity: Major
    Found in src_aurelia-bodylight-plugin/src/elements/value.js and 1 other location - About 2 hrs to fix
    src_aurelia-bodylight-plugin/src/elements/value.js on lines 125..129

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

    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

          } else {    
            //go with toPrecision function
            if (this.operation) this.value = this.operation[0](rawvalue).toPrecision(this.precision); // * this.numerator / this.denominator + this.addconst;
            else this.value = rawvalue.toPrecision(this.precision);
          }
    Severity: Major
    Found in src_aurelia-bodylight-plugin/src/elements/value.js and 1 other location - About 2 hrs to fix
    src_aurelia-bodylight-plugin/src/elements/value.js on lines 121..125

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

    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

        if (this.dataevent) {
          let c = new CustomEvent('fmivalue', {detail: {value: this.value}});
          this.element.dispatchEvent(c);
        }
    Severity: Minor
    Found in src_aurelia-bodylight-plugin/src/elements/value.js and 1 other location - About 55 mins to fix
    src_aurelia-bodylight-plugin/src/elements/value-boolean.js on lines 14..17

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

    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

        if (fromel) {
          fromel.addEventListener('fmidata', this.handleValueChange);
        } else {
          console.warn('chartjs, null fromid element, waiting to be attached');
          document.addEventListener('fmiattached',this.handleFMIAttached);
    Severity: Minor
    Found in src_aurelia-bodylight-plugin/src/elements/value.js and 1 other location - About 55 mins to fix
    src_aurelia-bodylight-plugin/src/elements/value-store.js on lines 42..47

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

    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

        if (this.adobeid && document.getElementById(this.adobeid)) document.getElementById(this.adobeid).removeEventListener('change', this.handleRawValueChange);
    Severity: Minor
    Found in src_aurelia-bodylight-plugin/src/elements/value.js and 1 other location - About 50 mins to fix
    src_aurelia-bodylight-plugin/src/elements/animate-control.js on lines 119..119

    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