Shuunen/repo-checker

View on GitHub

Showing 42 of 42 total issues

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

it('nyc rc D file exists but not a json ext file', async () => {
  const instance = new NycRcFile(vueProjectFolder, new ProjectData({ isQuiet: true, isUsingNyc: true }))
  await instance.start()
  await instance.end()
  expect(cleanInstanceForSnap(instance)).toMatchSnapshot()
Severity: Major
Found in src/files/nycrc.test.ts and 5 other locations - About 2 hrs to fix
src/files/npmrc.test.ts on lines 6..11
src/files/npmrc.test.ts on lines 13..18
src/files/npmrc.test.ts on lines 20..25
src/files/nycrc.test.ts on lines 6..11
src/files/package.test.ts on lines 35..40

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

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

it('npm rc A file exists & hasTaskPrefix', async () => {
  const instance = new NpmRcFile(repoCheckerPath, new ProjectData({ hasTaskPrefix: true, isQuiet: true }))
  await instance.start()
  await instance.end()
  expect(cleanInstanceForSnap(instance)).toMatchSnapshot()
Severity: Major
Found in src/files/npmrc.test.ts and 5 other locations - About 2 hrs to fix
src/files/npmrc.test.ts on lines 13..18
src/files/npmrc.test.ts on lines 20..25
src/files/nycrc.test.ts on lines 6..11
src/files/nycrc.test.ts on lines 28..33
src/files/package.test.ts on lines 35..40

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

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

it('nyc rc B check skip on a non nyc/c8 project', async () => {
  const instance = new NycRcFile(repoCheckerPath, new ProjectData({ isQuiet: true }))
  await instance.start()
  await instance.end()
  expect(cleanInstanceForSnap(instance)).toMatchSnapshot()
Severity: Major
Found in src/files/nycrc.test.ts and 2 other locations - About 2 hrs to fix
src/files/git.test.ts on lines 6..11
src/files/package.test.ts on lines 13..18

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

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

it('git : detect a missing git ignore', async () => {
  const instance = new GitFile(vueProjectFolder, new ProjectData({ isQuiet: true }))
  await instance.start()
  await instance.end()
  expect(cleanInstanceForSnap(instance)).toMatchSnapshot()
Severity: Major
Found in src/files/git.test.ts and 2 other locations - About 2 hrs to fix
src/files/nycrc.test.ts on lines 13..18
src/files/package.test.ts on lines 13..18

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

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

it('package B on ts project', async () => {
  const instance = new PackageJsonFile(tsProjectFolder, new ProjectData({ isQuiet: true }))
  await instance.start()
  await instance.end()
  expect(cleanInstanceForSnap(instance)).toMatchSnapshot()
Severity: Major
Found in src/files/package.test.ts and 2 other locations - About 2 hrs to fix
src/files/git.test.ts on lines 6..11
src/files/nycrc.test.ts on lines 13..18

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

Function getThanks has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private async getThanks() {
    const list = [
      new Thanks('Shields.io', 'https://shields.io', 'for the nice badges on top of this readme', this.fileContent.includes('shields')),
      new Thanks('Travis-ci.com', 'https://travis-ci.com', 'for providing free continuous deployments', this.fileContent.includes('travis-ci')),
      new Thanks('Github', 'https://github.com', 'for all their great work year after year, pushing OSS forward', this.fileContent.includes('github')),
Severity: Minor
Found in src/files/readme.ts - About 1 hr to fix

    Function findInFolder has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    export async function findInFolder(folderPath: string, pattern: Readonly<RegExp>, ignoredInput: readonly string[] = ['node_modules', '.git'], count = 0) {
      const filePaths = await readDirectoryAsync(folderPath)
      const matches: string[] = []
      let ignored = arrayUnique(ignoredInput)
      if (filePaths.includes('.gitignore')) {
    Severity: Minor
    Found in src/utils.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 checkCompilerOptions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      private checkCompilerOptions() {
        /* c8 ignore next 4 */
        if (this.fileContentObject === undefined) {
          log.error('cannot check compiler options without file content')
          return
    Severity: Minor
    Found in src/files/ts-config.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 shouldContains has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      public shouldContains(name: string, regex?: Readonly<RegExp>, nbMatchExpected = defaultAmount, willJustWarn = false, helpMessage = '', canFix = false) {
        // eslint-disable-next-line security/detect-non-literal-regexp
        const regexp = regex ?? new RegExp(name, 'u')
        const isOk = this.checkContains(regexp, nbMatchExpected)
        const willFix = this.canFix && canFix && !isOk
    Severity: Minor
    Found in src/file.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 augmentDataWithPackageJson has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    export async function augmentDataWithPackageJson(folderPath: string, dataSource: Readonly<ProjectData>) {
      const data = new ProjectData(dataSource)
      if (!(await fileExists(path.join(folderPath, 'package.json')))) {
        log.debug('cannot augment, no package.json found in', folderPath)
        return data
    Severity: Minor
    Found in src/utils.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 augmentDataWithPackageJson has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function augmentDataWithPackageJson(folderPath: string, dataSource: Readonly<ProjectData>) {
      const data = new ProjectData(dataSource)
      if (!(await fileExists(path.join(folderPath, 'package.json')))) {
        log.debug('cannot augment, no package.json found in', folderPath)
        return data
    Severity: Minor
    Found in src/utils.ts - About 1 hr to fix

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

      it('start C show version', async () => {
        const options = { ...defaultOptions, willShowVersion: true }
        expect(await start(options)).toMatchInlineSnapshot(`
          {
            "failed": [],
      Severity: Major
      Found in src/main.test.ts and 1 other location - About 1 hr to fix
      src/main.test.ts on lines 38..49

      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

      it('start B show help', async () => {
        const options = { ...defaultOptions, willShowHelp: true }
        expect(await start(options)).toMatchInlineSnapshot(`
          {
            "failed": [],
      Severity: Major
      Found in src/main.test.ts and 1 other location - About 1 hr to fix
      src/main.test.ts on lines 51..62

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

        private async checkThanks() {
          const hasSection = this.couldContains('a thanks section', /## Thanks/u)
          if (!hasSection) return
          const thanks = await this.getThanks()
          for (const thank of thanks) {
      Severity: Minor
      Found in src/files/readme.ts - About 55 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 check has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      export async function check({ canFailStop = false, canFix = false, canForce = false, canThrow = true, data, folderPath }: Readonly<CheckOptions>) {
        const folders = await getProjectFolders(folderPath)
        let passed: string[] = []
        let warnings: string[] = []
        let failed: string[] = []
      Severity: Minor
      Found in src/check.ts - About 55 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 4 locations. Consider refactoring.
      Open

      it('start E verbose', () => {
        const options = { ...defaultOptions, isVerbose: true }
        expect(start(options)).toMatchInlineSnapshot('Promise {}')
      })
      Severity: Major
      Found in src/main.test.ts and 3 other locations - About 40 mins to fix
      src/main.test.ts on lines 64..67
      src/main.test.ts on lines 74..77
      src/main.test.ts on lines 79..82

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

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

      it('start D init', () => {
        const options = { ...defaultOptions, willInit: true }
        expect(start(options)).toMatchInlineSnapshot('Promise {}')
      })
      Severity: Major
      Found in src/main.test.ts and 3 other locations - About 40 mins to fix
      src/main.test.ts on lines 69..72
      src/main.test.ts on lines 74..77
      src/main.test.ts on lines 79..82

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

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

      it('start G fix', () => {
        const options = { ...defaultOptions, canFix: true }
        expect(start(options)).toMatchInlineSnapshot('Promise {}')
      })
      Severity: Major
      Found in src/main.test.ts and 3 other locations - About 40 mins to fix
      src/main.test.ts on lines 64..67
      src/main.test.ts on lines 69..72
      src/main.test.ts on lines 74..77

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

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

      it('start F quiet', () => {
        const options = { ...defaultOptions, isQuiet: true }
        expect(start(options)).toMatchInlineSnapshot('Promise {}')
      })
      Severity: Major
      Found in src/main.test.ts and 3 other locations - About 40 mins to fix
      src/main.test.ts on lines 64..67
      src/main.test.ts on lines 69..72
      src/main.test.ts on lines 79..82

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

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

        private checkBadgesRecommended() {
          const badges = this.getBadgesRecommended()
          for (const badge of badges) {
            const message = `${badge.isExpected ? 'a' : 'no'} "${badge.label}" badge`
            // eslint-disable-next-line security/detect-non-literal-regexp, sonarjs/no-nested-template-literals
      Severity: Minor
      Found in src/files/readme.ts - About 35 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