JamieMason/eslint-plugin-prefer-arrow-functions

View on GitHub

Showing 15 of 15 total issues

File prefer-arrow-functions.spec.ts has 801 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { RuleTester } from 'eslint';

import rule from './prefer-arrow-functions';

import {
Severity: Major
Found in src/prefer-arrow-functions.spec.ts - About 1 day to fix

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

      create: (context) => {
        const options = context.options[0] || {};
        const getOption = (name) =>
          typeof options[name] !== 'undefined'
            ? options[name]
    Severity: Major
    Found in src/prefer-arrow-functions.ts - About 1 day to fix

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

        create: (context) => {
          const options = context.options[0] || {};
          const getOption = (name) =>
            typeof options[name] !== 'undefined'
              ? options[name]
      Severity: Minor
      Found in src/prefer-arrow-functions.ts - About 7 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

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

      describe('when returnStyle is "explicit"', () => {
        describe('when function is an arrow function with an implicit return', () => {
          describe('it fixes the function to have a block statement containing an immediate return', () => {
            ruleTester.run('lib/rules/prefer-arrow-functions', rule, {
              valid: [],
      Severity: Major
      Found in src/prefer-arrow-functions.spec.ts and 1 other location - About 3 hrs to fix
      src/prefer-arrow-functions.spec.ts on lines 840..851

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

      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

      describe('when returnStyle is "implicit"', () => {
        describe('when function is an arrow function with a block statement containing an immediate return', () => {
          describe('it fixes the function to have an implicit return', () => {
            ruleTester.run('lib/rules/prefer-arrow-functions', rule, {
              valid: [],
      Severity: Major
      Found in src/prefer-arrow-functions.spec.ts and 1 other location - About 3 hrs to fix
      src/prefer-arrow-functions.spec.ts on lines 853..864

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

      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 prefer-arrow-functions.ts has 273 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import {
        DEFAULT_OPTIONS,
        USE_ARROW_WHEN_FUNCTION,
        USE_ARROW_WHEN_SINGLE_RETURN,
        USE_EXPLICIT,
      Severity: Minor
      Found in src/prefer-arrow-functions.ts - About 2 hrs to fix

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

          describe('when two functions are featured: one returns immediately and the other has a block statement', () => {
            describe('it fixes the function which returns and considers the other valid', () => {
              ruleTester.run('lib/rules/prefer-arrow-functions', rule, {
                valid: [],
                invalid: invalidAndHasSingleReturnWithMultipleMatches
        Severity: Major
        Found in src/prefer-arrow-functions.spec.ts and 1 other location - About 2 hrs to fix
        src/prefer-arrow-functions.spec.ts on lines 736..745

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

        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

            describe('when function contains only a return statement', () => {
              describe('it fixes the function', () => {
                ruleTester.run('lib/rules/prefer-arrow-functions', rule, {
                  valid: [],
                  invalid: invalidAndHasSingleReturn
        Severity: Major
        Found in src/prefer-arrow-functions.spec.ts and 1 other location - About 2 hrs to fix
        src/prefer-arrow-functions.spec.ts on lines 747..756

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

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

              describe('when returnStyle is "explicit"', () => {
                ruleTester.run('lib/rules/prefer-arrow-functions', rule, {
                  valid: [],
                  invalid: invalidAndHasBlockStatement
                    .map(
        Severity: Major
        Found in src/prefer-arrow-functions.spec.ts and 2 other locations - About 2 hrs to fix
        src/prefer-arrow-functions.spec.ts on lines 784..793
        src/prefer-arrow-functions.spec.ts on lines 794..806

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

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

              describe('when returnStyle is "implicit"', () => {
                ruleTester.run('lib/rules/prefer-arrow-functions', rule, {
                  valid: [],
                  invalid: invalidAndHasBlockStatement
                    .map(
        Severity: Major
        Found in src/prefer-arrow-functions.spec.ts and 2 other locations - About 2 hrs to fix
        src/prefer-arrow-functions.spec.ts on lines 774..783
        src/prefer-arrow-functions.spec.ts on lines 794..806

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

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

              describe('when returnStyle is "unchanged" or not set', () => {
                ruleTester.run('lib/rules/prefer-arrow-functions', rule, {
                  valid: [],
                  invalid: invalidAndHasBlockStatement
                    .map(
        Severity: Major
        Found in src/prefer-arrow-functions.spec.ts and 2 other locations - About 2 hrs to fix
        src/prefer-arrow-functions.spec.ts on lines 774..783
        src/prefer-arrow-functions.spec.ts on lines 784..793

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

        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

              'ArrowFunctionExpression[body.type!="BlockStatement"]': (node) => {
                if (returnStyle === 'explicit' && isSafeTransformation(node)) {
                  context.report({
                    fix: (fixer) => fixer.replaceText(node, writeArrowFunction(node)),
                    message: USE_EXPLICIT,
        Severity: Major
        Found in src/prefer-arrow-functions.ts and 1 other location - About 1 hr to fix
        src/prefer-arrow-functions.ts on lines 263..272

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

        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

              'FunctionDeclaration[parent.type!="ExportDefaultDeclaration"]': (
                node,
              ) => {
                if (isSafeTransformation(node)) {
                  context.report({
        Severity: Major
        Found in src/prefer-arrow-functions.ts and 1 other location - About 1 hr to fix
        src/prefer-arrow-functions.ts on lines 223..232

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

        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

              'ArrowFunctionExpression[body.body.length=1][body.body.0.type="ReturnStatement"]':
                (node) => {
                  if (returnStyle === 'implicit' && isSafeTransformation(node)) {
                    context.report({
                      fix: (fixer) => fixer.replaceText(node, writeArrowFunction(node)),
        Severity: Major
        Found in src/prefer-arrow-functions.ts and 1 other location - About 1 hr to fix
        src/prefer-arrow-functions.ts on lines 254..262

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

        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

              'ExportDefaultDeclaration > FunctionDeclaration': (node) => {
                if (isSafeTransformation(node)) {
                  context.report({
                    fix: (fixer) =>
                      fixer.replaceText(node, writeArrowFunction(node) + ';'),
        Severity: Major
        Found in src/prefer-arrow-functions.ts and 1 other location - About 1 hr to fix
        src/prefer-arrow-functions.ts on lines 283..294

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

        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

        Severity
        Category
        Status
        Source
        Language