lib/modules/importHelper.js

Summary

Maintainability
D
2 days
Test Coverage

Function enhanceWithForm has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
Open

exports.enhanceWithForm = function(objCollection, formSchema) {

    if (formSchema && formSchema.$path) {

        var newCollection = [];
Severity: Minor
Found in lib/modules/importHelper.js - About 1 day 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 enhanceWithForm has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.enhanceWithForm = function(objCollection, formSchema) {

    if (formSchema && formSchema.$path) {

        var newCollection = [];
Severity: Major
Found in lib/modules/importHelper.js - About 3 hrs to fix

    Function validate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.validate = function(objCollection, registry) {
    
        var errors = 0;
    
        for (var i = 0; i < objCollection.length; i++) {
    Severity: Minor
    Found in lib/modules/importHelper.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 objToTemplate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.objToTemplate = function(name, obj) {
    
        if (!obj || Object.keys(obj).length === 0) {
            return '{{' + name + '}}\n'; // No unnecessary linebreaks
        }
    Severity: Minor
    Found in lib/modules/importHelper.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

    Avoid deeply nested control flow statements.
    Open

                } else if (template.wikitext) {
    
                    // Ignore "wikitext" properties, since they'll only be rendered on the form edit page
                    if (exports.settings.debug) {
                        log('[D] Ignoring form-only "wikitext" injection');
    Severity: Major
    Found in lib/modules/importHelper.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                      for (var i = 0; i < items.length; i++) {
                          if (exports.settings.verbose) {
                              log('[D] Inserting multiple instance template: ' + templateName);
                          }
                          newCollection.push(items[i]);
      Severity: Major
      Found in lib/modules/importHelper.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        if (exports.settings.verbose) {
                            log('[D] Appending wikitext: ' + obj);
                        }
        Severity: Major
        Found in lib/modules/importHelper.js - About 45 mins to fix

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

          exports.objCollectionToWikitext = function(objCollection) {
          
              var wikitext = '';
          
              for (var i = 0; i < objCollection.length; i++) {
          Severity: Minor
          Found in lib/modules/importHelper.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

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

          exports.objToFunction = function(name, obj) {
          
              var wikitext = '{{' + name + ':\n';
          
              for (var propertyName in obj) {
          Severity: Minor
          Found in lib/modules/importHelper.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

          There are no issues that match your filters.

          Category
          Status