yannickcr/eslint-plugin-react

View on GitHub
lib/rules/jsx-tag-spacing.js

Summary

Maintainability
F
1 wk
Test Coverage

File jsx-tag-spacing.js has 281 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @fileoverview Validates whitespace in and around the JSX opening and closing brackets
 * @author Diogo Franco (Kovensky)
 */

Severity: Minor
Found in lib/rules/jsx-tag-spacing.js - About 2 hrs to fix

    Function validateClosingSlash has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function validateClosingSlash(context, node, option) {
      const sourceCode = context.getSourceCode();
    
      let adjacent;
    
    
    Severity: Major
    Found in lib/rules/jsx-tag-spacing.js - About 2 hrs to fix

      Function validateBeforeClosing has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function validateBeforeClosing(context, node, option) {
        // Don't enforce this rule for self closing tags
        if (!node.selfClosing) {
          const sourceCode = context.getSourceCode();
          const leftToken = option === 'proportional-always'
      Severity: Major
      Found in lib/rules/jsx-tag-spacing.js - About 2 hrs to fix

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

        function validateClosingSlash(context, node, option) {
          const sourceCode = context.getSourceCode();
        
          let adjacent;
        
        
        Severity: Minor
        Found in lib/rules/jsx-tag-spacing.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 validateBeforeClosing has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        function validateBeforeClosing(context, node, option) {
          // Don't enforce this rule for self closing tags
          if (!node.selfClosing) {
            const sourceCode = context.getSourceCode();
            const leftToken = option === 'proportional-always'
        Severity: Minor
        Found in lib/rules/jsx-tag-spacing.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 create has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          create(context) {
            const options = Object.assign({}, optionDefaults, context.options[0]);
        
            return {
              JSXOpeningElement(node) {
        Severity: Minor
        Found in lib/rules/jsx-tag-spacing.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 validateBeforeSelfClosing has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function validateBeforeSelfClosing(context, node, option) {
          const sourceCode = context.getSourceCode();
          const leftToken = getTokenBeforeClosingBracket(node);
          const closingSlash = sourceCode.getTokenAfter(leftToken);
        
        
        Severity: Minor
        Found in lib/rules/jsx-tag-spacing.js - About 1 hr to fix

          Function validateAfterOpening has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function validateAfterOpening(context, node, option) {
            const sourceCode = context.getSourceCode();
            const openingToken = sourceCode.getTokenBefore(node.name);
          
            if (option === 'allow-multiline') {
          Severity: Minor
          Found in lib/rules/jsx-tag-spacing.js - About 1 hr to fix

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

              create(context) {
                const options = Object.assign({}, optionDefaults, context.options[0]);
            
                return {
                  JSXOpeningElement(node) {
            Severity: Minor
            Found in lib/rules/jsx-tag-spacing.js - About 1 hr to fix

              Function validateAfterOpening has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              function validateAfterOpening(context, node, option) {
                const sourceCode = context.getSourceCode();
                const openingToken = sourceCode.getTokenBefore(node.name);
              
                if (option === 'allow-multiline') {
              Severity: Minor
              Found in lib/rules/jsx-tag-spacing.js - About 45 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 validateBeforeSelfClosing has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              function validateBeforeSelfClosing(context, node, option) {
                const sourceCode = context.getSourceCode();
                const leftToken = getTokenBeforeClosingBracket(node);
                const closingSlash = sourceCode.getTokenAfter(leftToken);
              
              
              Severity: Minor
              Found in lib/rules/jsx-tag-spacing.js - About 45 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

                } else {
                  const firstTokens = sourceCode.getFirstTokens(node, 2);
              
                  adjacent = !sourceCode.isSpaceBetweenTokens(firstTokens[0], firstTokens[1]);
              
              
              Severity: Major
              Found in lib/rules/jsx-tag-spacing.js and 1 other location - About 1 day to fix
              lib/rules/jsx-tag-spacing.js on lines 36..66

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

              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 (node.selfClosing) {
                  const lastTokens = sourceCode.getLastTokens(node, 2);
              
                  adjacent = !sourceCode.isSpaceBetweenTokens(lastTokens[0], lastTokens[1]);
              
              
              Severity: Major
              Found in lib/rules/jsx-tag-spacing.js and 1 other location - About 1 day to fix
              lib/rules/jsx-tag-spacing.js on lines 66..96

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

              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 (node.loc.start.line !== node.loc.end.line && option === 'proportional-always') {
                  if (leftToken.loc.end.line === closingSlash.loc.start.line) {
                    report(context, messages.beforeSelfCloseNeedNewline, 'beforeSelfCloseNeedNewline', {
                      node,
                      loc: leftToken.loc.end,
              Severity: Major
              Found in lib/rules/jsx-tag-spacing.js and 1 other location - About 4 hrs to fix
              lib/rules/jsx-tag-spacing.js on lines 191..202

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

              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 (node.loc.start.line !== node.loc.end.line && option === 'proportional-always') {
                    if (leftToken.loc.end.line === closingToken.loc.start.line) {
                      report(context, messages.beforeCloseNeedNewline, 'beforeCloseNeedNewline', {
                        node,
                        loc: leftToken.loc.end,
              Severity: Major
              Found in lib/rules/jsx-tag-spacing.js and 1 other location - About 4 hrs to fix
              lib/rules/jsx-tag-spacing.js on lines 104..115

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

              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 (option === 'proportional-always' && node.type === 'JSXOpeningElement' && adjacent !== (node.loc.start.line === node.loc.end.line)) {
                    report(context, messages.beforeCloseNeedSpace, 'beforeCloseNeedSpace', {
                      node,
                      loc: {
                        start: leftToken.loc.end,
              Severity: Major
              Found in lib/rules/jsx-tag-spacing.js and 1 other location - About 2 hrs to fix
              lib/rules/jsx-tag-spacing.js on lines 221..243

              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

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

                  } else if (option === 'always' && adjacent) {
                    report(context, messages.beforeCloseNeedSpace, 'beforeCloseNeedSpace', {
                      node,
                      loc: {
                        start: leftToken.loc.end,
              Severity: Major
              Found in lib/rules/jsx-tag-spacing.js and 1 other location - About 2 hrs to fix
              lib/rules/jsx-tag-spacing.js on lines 232..243

              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

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

                    fix(fixer) {
                      const previousToken = sourceCode.getTokenBefore(closingSlash);
                      return fixer.removeRange([previousToken.range[1], closingSlash.range[0]]);
                    },
              Severity: Minor
              Found in lib/rules/jsx-tag-spacing.js and 1 other location - About 55 mins to fix
              lib/rules/jsx-space-before-closing.js on lines 76..79

              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

              There are no issues that match your filters.

              Category
              Status