JamieMason/eslint-plugin-move-files

View on GitHub

Showing 26 of 26 total issues

File move-files.spec.ts has 360 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { RuleTester } from 'eslint';
import { existsSync, readFileSync } from 'fs';
import * as mock from 'mock-fs';
import { resolve } from 'path';
import rule from './move-files';
Severity: Minor
Found in src/move-files.spec.ts - About 4 hrs to fix

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

      tests.forEach(([absolutePath, assertions]) => {
        describe(`when path is '${absolutePath}'`, () => {
          assertions.forEach(([query, expected]) => {
            describe(`when query is '${query}'`, () => {
              it(`returns '${expected}'`, () => {
    Severity: Major
    Found in src/lib/path-reader.spec.ts and 1 other location - About 4 hrs to fix
    src/lib/path-reader.spec.ts on lines 129..139

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

    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

      tests.forEach(([absolutePath, assertions]) => {
        describe(`when path is '${absolutePath}'`, () => {
          assertions.forEach(([template, expected]) => {
            describe(`when template is '${template}'`, () => {
              it(`returns '${expected}'`, () => {
    Severity: Major
    Found in src/lib/path-reader.spec.ts and 1 other location - About 4 hrs to fix
    src/lib/path-reader.spec.ts on lines 97..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 126.

    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

        return context.report({
          fix: (fixer) =>
            fixer.replaceText(
              node,
              context
    Severity: Major
    Found in src/move-files.ts and 1 other location - About 3 hrs to fix
    src/move-files.ts on lines 62..76

    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

        return context.report({
          fix: (fixer) =>
            fixer.replaceText(
              node,
              context
    Severity: Major
    Found in src/move-files.ts and 1 other location - About 3 hrs to fix
    src/move-files.ts on lines 96..110

    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

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

      create: (context) => {
        const currentFilePath = context.getFilename();
        const dirPath = dirname(currentFilePath);
    
        if (visitedFiles[currentFilePath]) {
    Severity: Major
    Found in src/move-files.ts - About 2 hrs to fix

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

        {
          description: 'convert a flat directory of files into module folders',
          fileSystem: [
            {
              path: ['./src/services/a.js', './src/services/a/index.js'],
      Severity: Major
      Found in src/move-files.spec.ts and 1 other location - About 1 hr to fix
      src/move-files.spec.ts on lines 121..143

      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

        {
          description: 'use .jsx extension in all React components',
          fileSystem: [
            {
              path: ['./src/components/Button.js', './src/components/Button.jsx'],
      Severity: Major
      Found in src/move-files.spec.ts and 1 other location - About 1 hr to fix
      src/move-files.spec.ts on lines 101..120

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

          [
            resolve(PWD, './.babelrc'),
            [
              ['...', ''],
              ['..', ''],
      Severity: Major
      Found in src/lib/path-reader.spec.ts and 2 other locations - About 1 hr to fix
      src/lib/path-reader.spec.ts on lines 38..56
      src/lib/path-reader.spec.ts on lines 76..94

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

      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

          [
            resolve(PWD, './src/lib/module.spec.js'),
            [
              ['...', 'src'],
              ['..', 'lib'],
      Severity: Major
      Found in src/lib/path-reader.spec.ts and 2 other locations - About 1 hr to fix
      src/lib/path-reader.spec.ts on lines 57..75
      src/lib/path-reader.spec.ts on lines 76..94

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

      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

          [
            resolve(PWD, './.eslintrc.js'),
            [
              ['...', ''],
              ['..', ''],
      Severity: Major
      Found in src/lib/path-reader.spec.ts and 2 other locations - About 1 hr to fix
      src/lib/path-reader.spec.ts on lines 38..56
      src/lib/path-reader.spec.ts on lines 57..75

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

      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 getValue has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const getValue = (query: string, absPath: string) => {
        if (query === 'rootDir') {
          return getRootDir();
        }
        if (query === 'dir') {
      Severity: Minor
      Found in src/lib/path-reader.ts - About 1 hr to fix

        Function getValue has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        export const getValue = (query: string, absPath: string) => {
          if (query === 'rootDir') {
            return getRootDir();
          }
          if (query === 'dir') {
        Severity: Minor
        Found in src/lib/path-reader.ts - 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 updateMovedFile has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const updateMovedFile = (
          context: Rule.RuleContext,
          fileIndex: FileIndex,
          fileDirPath: string,
          newFilePath: string,
        Severity: Minor
        Found in src/move-files.ts - About 1 hr to fix

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

            {
              description: 'convert files with a specific name into module folders',
              fileSystem: [
                {
                  path: ['./src/button/story.js', './src/button/story/index.js'],
          Severity: Minor
          Found in src/move-files.spec.ts and 1 other location - About 50 mins to fix
          src/move-files.spec.ts on lines 86..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 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

            {
              description: 'move a file into a sibling of its current directory',
              fileSystem: [
                {
                  path: ['./src/server.test.js', './test/server.js'],
          Severity: Minor
          Found in src/move-files.spec.ts and 1 other location - About 50 mins to fix
          src/move-files.spec.ts on lines 202..216

          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

          Avoid too many return statements within this function.
          Open

              return getIn(getDirsIndex(query), getDirs(absPath), '');
          Severity: Major
          Found in src/lib/path-reader.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return getIn(getAncestorsIndex(query), getAncestors(absPath), '');
            Severity: Major
            Found in src/lib/path-reader.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return getIn(getExtsIndex(query), getExts(absPath), '');
              Severity: Major
              Found in src/lib/path-reader.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return getExt(absPath);
                Severity: Major
                Found in src/lib/path-reader.ts - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language