yannickcr/eslint-plugin-react

View on GitHub
lib/rules/no-invalid-html-attribute.js

Summary

Maintainability
F
5 days
Test Coverage

File no-invalid-html-attribute.js has 545 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @fileoverview Check if tag attributes to have non-valid value
 * @author Sebastian Malton
 */

Severity: Major
Found in lib/rules/no-invalid-html-attribute.js - About 1 day to fix

    Function checkLiteralValueNode has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

    function checkLiteralValueNode(context, attributeName, node, parentNode, parentNodeName) {
      if (typeof node.value !== 'string') {
        report(context, messages.onlyStrings, 'onlyStrings', {
          node,
          data: { attributeName },
    Severity: Minor
    Found in lib/rules/no-invalid-html-attribute.js - About 5 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 checkLiteralValueNode has 113 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function checkLiteralValueNode(context, attributeName, node, parentNode, parentNodeName) {
      if (typeof node.value !== 'string') {
        report(context, messages.onlyStrings, 'onlyStrings', {
          node,
          data: { attributeName },
    Severity: Major
    Found in lib/rules/no-invalid-html-attribute.js - About 4 hrs to fix

      Function checkAttribute has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function checkAttribute(context, node) {
        const attribute = node.name.name;
      
        const parentNodeName = node.parent.name.name;
        if (!COMPONENT_ATTRIBUTE_MAP.has(attribute) || !COMPONENT_ATTRIBUTE_MAP.get(attribute).has(parentNodeName)) {
      Severity: Major
      Found in lib/rules/no-invalid-html-attribute.js - About 2 hrs to fix

        Function checkCreateProps has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        function checkCreateProps(context, node, attribute) {
          const propsArg = node.arguments[1];
        
          if (!propsArg || propsArg.type !== 'ObjectExpression') {
            return; // can't check variables, computed, or shorthands
        Severity: Minor
        Found in lib/rules/no-invalid-html-attribute.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 checkCreateProps has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function checkCreateProps(context, node, attribute) {
          const propsArg = node.arguments[1];
        
          if (!propsArg || propsArg.type !== 'ObjectExpression') {
            return; // can't check variables, computed, or shorthands
        Severity: Minor
        Found in lib/rules/no-invalid-html-attribute.js - About 1 hr to fix

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

            create(context) {
              return {
                JSXAttribute(node) {
                  const attributes = new Set(context.options[0] || DEFAULT_ATTRIBUTES);
          
          
          Severity: Minor
          Found in lib/rules/no-invalid-html-attribute.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 checkPropValidValue has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function checkPropValidValue(context, node, value, attribute) {
            const validTags = VALID_VALUES.get(attribute);
          
            if (value.type !== 'Literal') {
              return; // cannot check non-literals
          Severity: Minor
          Found in lib/rules/no-invalid-html-attribute.js - About 1 hr to fix

            Function create has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              create(context) {
                return {
                  JSXAttribute(node) {
                    const attributes = new Set(context.options[0] || DEFAULT_ATTRIBUTES);
            
            
            Severity: Minor
            Found in lib/rules/no-invalid-html-attribute.js - About 1 hr to fix

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

              function checkAttribute(context, node) {
                const attribute = node.name.name;
              
                const parentNodeName = node.parent.name.name;
                if (!COMPONENT_ATTRIBUTE_MAP.has(attribute) || !COMPONENT_ATTRIBUTE_MAP.get(attribute).has(parentNodeName)) {
              Severity: Minor
              Found in lib/rules/no-invalid-html-attribute.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 (!siblings.has(lastValue)) {
                          const message = secondValue ? messages.notPaired : messages.notAlone;
                          const messageId = secondValue ? 'notPaired' : 'notAlone';
                          report(context, message, messageId, {
                            node,
              Severity: Major
              Found in lib/rules/no-invalid-html-attribute.js - About 45 mins to fix

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

                function checkLiteralValueNode(context, attributeName, node, parentNode, parentNodeName) {
                Severity: Minor
                Found in lib/rules/no-invalid-html-attribute.js - About 35 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return;
                  Severity: Major
                  Found in lib/rules/no-invalid-html-attribute.js - About 30 mins to fix

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

                          report(context, messages.spaceDelimited, 'spaceDelimited', {
                            node,
                            data: { attributeName },
                            suggest: [
                              Object.assign(
                    Severity: Major
                    Found in lib/rules/no-invalid-html-attribute.js and 1 other location - About 2 hrs to fix
                    lib/rules/no-invalid-html-attribute.js on lines 276..285

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

                    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

                        report(context, messages.noEmpty, 'noEmpty', {
                          node,
                          data: { attributeName },
                          suggest: [
                            Object.assign(
                    Severity: Major
                    Found in lib/rules/no-invalid-html-attribute.js and 1 other location - About 2 hrs to fix
                    lib/rules/no-invalid-html-attribute.js on lines 357..366

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

                    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 (node.value.expression.type === 'ObjectExpression') {
                        report(context, messages.onlyStrings, 'onlyStrings', {
                          node: node.value,
                          data: { attributeName: attribute },
                          suggest: [
                    Severity: Major
                    Found in lib/rules/no-invalid-html-attribute.js and 1 other location - About 1 hr to fix
                    lib/rules/no-invalid-html-attribute.js on lines 448..459

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

                    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

                      } else if (node.value.expression.type === 'Identifier' && node.value.expression.name === 'undefined') {
                        report(context, messages.onlyStrings, 'onlyStrings', {
                          node: node.value,
                          data: { attributeName: attribute },
                          suggest: [
                    Severity: Major
                    Found in lib/rules/no-invalid-html-attribute.js and 1 other location - About 1 hr to fix
                    lib/rules/no-invalid-html-attribute.js on lines 437..459

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

                    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

                          const tagNames = Array.from(
                            COMPONENT_ATTRIBUTE_MAP.get(attribute).values(),
                            (tagName) => `"<${tagName}>"`
                          ).join(', ');
                    Severity: Minor
                    Found in lib/rules/no-invalid-html-attribute.js and 1 other location - About 50 mins to fix
                    lib/rules/no-invalid-html-attribute.js on lines 389..392

                    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

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

                        const tagNames = Array.from(
                          COMPONENT_ATTRIBUTE_MAP.get(attribute).values(),
                          (tagName) => `"<${tagName}>"`
                        ).join(', ');
                    Severity: Minor
                    Found in lib/rules/no-invalid-html-attribute.js and 1 other location - About 50 mins to fix
                    lib/rules/no-invalid-html-attribute.js on lines 530..533

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

                          suggest: [
                            Object.assign(
                              getMessageData('suggestRemoveNonString', messages.suggestRemoveNonString),
                              { fix(fixer) { return fixer.remove(parentNode); } }
                            ),
                    Severity: Minor
                    Found in lib/rules/no-invalid-html-attribute.js and 1 other location - About 35 mins to fix
                    lib/rules/no-invalid-html-attribute.js on lines 399..404

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

                    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

                          suggest: [
                            Object.assign(
                              getMessageData('suggestRemoveDefault', messages.suggestRemoveDefault),
                              { fix(fixer) { return fixer.remove(node); } }
                            ),
                    Severity: Minor
                    Found in lib/rules/no-invalid-html-attribute.js and 1 other location - About 35 mins to fix
                    lib/rules/no-invalid-html-attribute.js on lines 265..270

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

                    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