SiLeBAT/FSK-Lab

View on GitHub
de.bund.bfr.knime.js/src/js/app/app.utils.js

Summary

Maintainability
F
4 days
Test Coverage

File app.utils.js has 302 lines of code (exceeds 250 allowed). Consider refactoring.
Open

 /** Temporary workaround for some metadata glitches. */
 var metadataFix = (metadata) =>   {
    // Ignore temporarily publication type
    // TODO: publicationType takes the abbreviation instead of the full string
    // used in the Reference dialog. Since KNIME runs getComponentValue twice,
Severity: Minor
Found in de.bund.bfr.knime.js/src/js/app/app.utils.js - About 3 hrs to fix

Function createForm has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

var createForm = (prop, value, port) =>   {
    let isMandatory = prop.required ? prop.required : false;

    if (prop.type === "text" || prop.type === "number" || prop.type === "url" ||
        prop.type === "date" || prop.type === "email"  || prop.type === "year_date")
Severity: Minor
Found in de.bund.bfr.knime.js/src/js/app/app.utils.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

Consider simplifying this complex logical expression.
Open

    if ( _isUndefined( value ) 
        || _isNull( value ) 
        || typeof value == 'object' && Object.keys( value ).length === 0 && value.constructor === Object
        || typeof value == 'object' && value.length == 1 && _isNull( value[0] )
        || value.length <= 0 ) {
Severity: Critical
Found in de.bund.bfr.knime.js/src/js/app/app.utils.js - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

    if (prop.type === "text" || prop.type === "number" || prop.type === "url" ||
        prop.type === "date" || prop.type === "email"  || prop.type === "year_date")
        return new InputForm(prop.label, isMandatory, prop.type, prop.description,
            value ? value : "", port, prop.vocabulary, prop.sid);
    
Severity: Major
Found in de.bund.bfr.knime.js/src/js/app/app.utils.js - About 40 mins to fix

Avoid too many return statements within this function.
Open

        return new ArrayForm(prop.label, isMandatory, prop.type,
            value ? value : [], prop.description, port, prop.vocabulary);
Severity: Major
Found in de.bund.bfr.knime.js/src/js/app/app.utils.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return _sorter._executionArray(array_a, array_b);
Severity: Major
Found in de.bund.bfr.knime.js/src/js/app/app.utils.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return new ArrayForm(prop.label, isMandatory, prop.type,
            value ? value : [], prop.description, port, prop.vocabulary);
Severity: Major
Found in de.bund.bfr.knime.js/src/js/app/app.utils.js - About 30 mins to fix

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

    _blob         : async ( src, id, signal ) => {
        _log( 'UTILS / _fetchData._blob: '+ src + ', '+ id + ', ' + window._token);
        let data = null;
        // append id if not type "set"
        src = ! _isNull( id ) ? src + id + window._token: src  + window._token;
Severity: Minor
Found in de.bund.bfr.knime.js/src/js/app/app.utils.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

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

    _metadataDate: function _metadataDate(data) {
        if(data && data.constructor == Array) {
            var dTemp = new Date(data);
            if (Object.prototype.toString.call(dTemp) === "[object Date]") {
            // it is a date
Severity: Minor
Found in de.bund.bfr.knime.js/src/js/app/app.utils.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

    _json         : async ( src, id, signal ) => {
        _log( 'UTILS / _fetchData._json: '+ src + ', '+ id + ', ' + window._token);
        let data = null;
        // append id if not type "set"
        src = ! _isNull( id ) ? src + id + window._token: src + window._token;
Severity: Major
Found in de.bund.bfr.knime.js/src/js/app/app.utils.js and 1 other location - About 1 day to fix
de.bund.bfr.knime.js/src/js/app/app.utils.js on lines 343..365

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

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

    _content     : async ( src, id, signal ) => {
        _log( 'UTILS / _fetchData._content: '+ src + ', '+ id + ', ' + window._token);
        let data = null;
        // append id if not type "set"
        src = ! _isNull( id ) ? src + id + window._token : src + window._token;
Severity: Major
Found in de.bund.bfr.knime.js/src/js/app/app.utils.js and 1 other location - About 1 day to fix
de.bund.bfr.knime.js/src/js/app/app.utils.js on lines 296..318

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

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

var createLabel = (name, isMandatory, description)  =>   {
    let label = document.createElement("label");
    label.classList.add("col-sm-2", "control-label");
    label.title = description;
    label.setAttribute("data-toggle", "tooltip");
Severity: Major
Found in de.bund.bfr.knime.js/src/js/app/app.utils.js and 2 other locations - About 3 hrs to fix
de.bund.bfr.knime.fsklab.deprecatednodes/js-src/de/bund/bfr/knime/fsklab/1.7.2/editor/editor.js on lines 2779..2789
de.bund.bfr.knime.js/js-lib/bfr/fskutil_1.0.0.js on lines 26..36

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

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

 var metadataFix = (metadata) =>   {
    // Ignore temporarily publication type
    // TODO: publicationType takes the abbreviation instead of the full string
    // used in the Reference dialog. Since KNIME runs getComponentValue twice,
    // the value cannot be converted here. The 1st call to getComponentValue
Severity: Major
Found in de.bund.bfr.knime.js/src/js/app/app.utils.js and 1 other location - About 2 hrs to fix
de.bund.bfr.knime.js/js-lib/bfr/fskutil_1.0.0.js on lines 6..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 77.

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

var createSubMenu = (name, submenus)  =>   {
    return `<li class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button"
        aria-haspopup="true" aria-expanded="false">${name}<span class="caret"></a>
    <ul class="dropdown-menu">
Severity: Major
Found in de.bund.bfr.knime.js/src/js/app/app.utils.js and 2 other locations - About 1 hr to fix
de.bund.bfr.knime.fsklab.deprecatednodes/js-src/de/bund/bfr/knime/fsklab/1.7.2/editor/editor.js on lines 2756..2766
de.bund.bfr.knime.js/js-lib/bfr/fskutil_1.0.0.js on lines 43..52

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

    if (prop.type === "text" || prop.type === "number" || prop.type === "url" ||
        prop.type === "date" || prop.type === "email"  || prop.type === "year_date")
Severity: Major
Found in de.bund.bfr.knime.js/src/js/app/app.utils.js and 1 other location - About 1 hr to fix
de.bund.bfr.knime.js/js-lib/bfr/fskutil_1.0.0.js on lines 725..726

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

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

        let styles = {
            primary     : 'background: #000; color:#fff; padding: 1px 2px;',
            secondary     : 'background: #aaa; color:#fff; padding: 1px 2px;',
            level1        : 'padding-left: 10px',
            level2        : 'padding-left: 20px',
Severity: Minor
Found in de.bund.bfr.knime.js/src/js/app/app.utils.js and 1 other location - About 40 mins to fix
de.bund.bfr.knime.pmm.nodes/js-src/de/bund/bfr/knime/pmm/js/modelplotter/d3.js on lines 8319..8328

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

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