yannickcr/eslint-plugin-react

View on GitHub

Showing 696 of 696 total issues

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

function testUpperCase(char) {
  const upperCase = char.toUpperCase();
  return char === upperCase && upperCase !== char.toLowerCase();
}
Severity: Minor
Found in lib/rules/jsx-pascal-case.js and 1 other location - About 30 mins to fix
lib/rules/jsx-pascal-case.js on lines 24..27

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

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

Avoid too many return statements within this function.
Open

          return;
Severity: Major
Found in lib/rules/no-unknown-property.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

              return;
    Severity: Major
    Found in lib/rules/no-unknown-property.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                return prev;
      Severity: Major
      Found in lib/rules/sort-prop-types.js - About 30 mins to fix

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

              if (node.parent.type === 'MemberExpression' && node.parent.parent
                && node.parent.parent.type === 'AssignmentExpression') {
        Severity: Minor
        Found in lib/util/defaultProps.js and 1 other location - About 30 mins to fix
        lib/util/Components.js on lines 374..376

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

        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

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

        function isSuperTypeParameterPropsDeclaration(node) {
          if (node && (node.type === 'ClassDeclaration' || node.type === 'ClassExpression')) {
            if (node.superTypeParameters && node.superTypeParameters.params.length > 0) {
              return true;
            }
        Severity: Minor
        Found in lib/util/propTypes.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          create(context) {
            const configuration = context.options[0] || 'always';
        
            return {
              ObjectExpression(node) {
        Severity: Minor
        Found in lib/rules/prefer-es6-class.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 isPropTypesDeclaration has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function isPropTypesDeclaration(node) {
          if (node && (node.type === 'ClassProperty' || node.type === 'PropertyDefinition')) {
            // Flow support
            if (node.typeAnnotation && node.key.name === 'props') {
              return true;
        Severity: Minor
        Found in lib/util/props.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 iterateProperties has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function iterateProperties(context, properties, fn, handleSpreadFn) {
          if (properties && properties.length && typeof fn === 'function') {
            for (let i = 0, j = properties.length; i < j; i++) {
              const node = properties[i];
              const key = astUtil.getKeyValue(context, node);
        Severity: Minor
        Found in lib/util/propTypes.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 isAnnotatedFunctionPropsDeclaration has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function isAnnotatedFunctionPropsDeclaration(node, context) {
          if (!node || !node.params || !node.params.length) {
            return false;
          }
        
        
        Severity: Minor
        Found in lib/util/annotations.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 isCreateContext has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function isCreateContext(node) {
          if (
            node.init
            && node.init.type === 'CallExpression'
            && node.init.callee
        Severity: Minor
        Found in lib/util/isCreateContext.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 traverseReturns has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function traverseReturns(ASTNode, context, onReturn) {
          const nodeType = ASTNode.type;
        
          if (nodeType === 'ReturnStatement') {
            onReturn(ASTNode.argument, () => {});
        Severity: Minor
        Found in lib/util/ast.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          create(context) {
            const option = context.options[0] || 'always';
            return {
              'ClassProperty, PropertyDefinition'(node) {
                if (
        Severity: Minor
        Found in lib/rules/state-in-constructor.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          create: Components.detect((context, components, utils) => {
            const configuration = context.options[0] || {};
            const ignoreStateless = configuration.ignoreStateless || false;
        
            /**
        Severity: Minor
        Found in lib/rules/no-multi-comp.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 getMethodsOrder has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function getMethodsOrder(userConfig) {
          userConfig = userConfig || {};
        
          const groups = Object.assign({}, defaultConfig.groups, userConfig.groups);
          const order = userConfig.order || defaultConfig.order;
        Severity: Minor
        Found in lib/rules/sort-comp.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 testAllCaps has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function testAllCaps(name) {
          const firstChar = name.charAt(0);
          if (!(testUpperCase(firstChar) || testDigit(firstChar))) {
            return false;
          }
        Severity: Minor
        Found in lib/rules/jsx-pascal-case.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

        Severity
        Category
        Status
        Source
        Language