public-js/eslint-plugin-react-native

View on GitHub

Showing 16 of 16 total issues

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

function create(context: TSESLint.RuleContext<keyof typeof MessageCodes, typeof schema>): TSESLint.RuleListener {
    const { borderInBoxModel }: { borderInBoxModel: boolean } = {
        borderInBoxModel: false,
        ...context.options[0],
    };

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

                for (let i = 0; i < properties.length; i += 1) {
                    const property = properties[i];
                    if (property.type === AST_NODE_TYPES.Property) {
                        chunk.push(property);
                    } else if (chunk.length) {
    packages/eslint-plugin-react-native/src/rules/utils/ast-helpers-react-native.ts on lines 99..107

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

    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

            for (let i = 0; i < properties.length; i += 1) {
                const property = properties[i];
                if (property.type === AST_NODE_TYPES.Property) {
                    chunk.push(property);
                } else if (chunk.length) {
    packages/eslint-plugin-react-native/src/rules/utils/ast-helpers-react-native.ts on lines 79..87

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

    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

        getPropertyName: function (node: TSESTree.Node): string | void {
            if (node && 'property' in node && node.property && 'name' in node.property && node.property.name) {
                return node.property.name.toString();
            }
        },
    packages/eslint-plugin-react-native/src/rules/utils/ast-helpers-react-native.ts on lines 350..354

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

    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

        getObjectName: function (node: TSESTree.Node): string | void {
            if (node && 'object' in node && node.object && 'name' in node.object && node.object.name) {
                return node.object.name.toString();
            }
        },
    packages/eslint-plugin-react-native/src/rules/utils/ast-helpers-react-native.ts on lines 356..360

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

    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

    File stylesheet-rational-order-groups.ts has 256 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* 1. Positioning */
    const positioning: string[] = ['position', 'top', 'right', 'bottom', 'left', 'zIndex'];
    
    /* Border */
    const borderProps: string[] = [

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

      function create(context: TSESLint.RuleContext<keyof typeof MessageCodes, typeof schema>): TSESLint.RuleListener {
          const { borderInBoxModel }: { borderInBoxModel: boolean } = {
              borderInBoxModel: false,
              ...context.options[0],
          };

      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

      const typography: string[] = [
          'color',
          'font',
          'fontWeight',
          'fontSize',
      packages/eslint-plugin-react-native/src/rules/utils/stylesheet-rational-order-groups.ts on lines 42..100

      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

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

      const boxModelPart1: string[] = [
          'display',
          'flex',
          'flexBasis',
          'flexDirection',
      packages/eslint-plugin-react-native/src/rules/utils/stylesheet-rational-order-groups.ts on lines 106..164

      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

      Function getStyleDeclarationsChunks has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          getStyleDeclarationsChunks: function (node: TSESTree.Node): ESTreeProp[][] {
              if (
                  node &&
                  node.type === AST_NODE_TYPES.CallExpression &&
                  node.arguments &&

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

        const visual = ({ border }: { border: boolean }): string[] =>
            [].concat(visualPart1, border ? borderProps : [], visualPart2);
        packages/eslint-plugin-react-native/src/rules/utils/stylesheet-rational-order-groups.ts on lines 102..103

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

        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

        const boxModel = ({ border }: { border: boolean }): string[] =>
            [].concat(boxModelPart1, border ? borderProps : [], boxModelPart2);
        packages/eslint-plugin-react-native/src/rules/utils/stylesheet-rational-order-groups.ts on lines 210..211

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

        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 getStyleDeclarationsChunks has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            getStyleDeclarationsChunks: function (node: TSESTree.Node): ESTreeProp[][] {
                if (
                    node &&
                    node.type === AST_NODE_TYPES.CallExpression &&
                    node.arguments &&

        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 (
                    node &&
                    node.type === AST_NODE_TYPES.CallExpression &&
                    node.arguments &&
                    node.arguments[0] &&

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

              function report(array: TSESTree.Node[], type: any, node: any, prev: TSESTree.Property, current: TSESTree.Property) {

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

                getExpressionIdentifier: function (node: TSESTree.Node): string {
                    if (node) {
                        switch (node.type) {
                            case AST_NODE_TYPES.Identifier:
                                return node.name;

            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