e-cloud/copyrightizen

View on GitHub

Showing 16 of 16 total issues

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

    test('with value as `copyright`', async () => {
      const originExit = process.exit
      const originLogErr = console.error
      const mockedExit: any = jest.fn(() => {throw new Error('exit')})
      process.exit = mockedExit
Severity: Major
Found in e2e/cli.test.ts and 1 other location - About 6 hrs to fix
e2e/cli.test.ts on lines 49..68

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

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

    test('with value as `copyright`', async () => {
      const originExit = process.exit
      const originLogErr = console.error
      const mockedExit: any = jest.fn(() => {throw new Error('exit')})
      process.exit = mockedExit
Severity: Major
Found in e2e/cli.test.ts and 1 other location - About 6 hrs to fix
e2e/cli.test.ts on lines 28..47

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

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('Unsupported extensions tests', () => {
  test('it should not change anything', async () => {
    const { tmpDir, refDir } = await copyReferenceDirectory('unsupported-exts')
    await runCopyrightizen(tmpDir);

Severity: Major
Found in e2e/unsupported-exts.test.ts and 2 other locations - About 4 hrs to fix
e2e/scopes.test.ts on lines 7..17
e2e/scopes.test.ts on lines 19..29

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

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('multiple scopes intersection', () => {
    test('it should handle scopes correctly', async () => {
      const { tmpDir, refDir } = await copyReferenceDirectory('multi-intersected-scopes')
      await runCopyrightizen(tmpDir);

Severity: Major
Found in e2e/scopes.test.ts and 2 other locations - About 4 hrs to fix
e2e/scopes.test.ts on lines 7..17
e2e/unsupported-exts.test.ts on lines 5..15

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

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('scopes precedence', () => {
    test('it should handle scopes precedence correctly', async () => {
      const { tmpDir, refDir } = await copyReferenceDirectory('scopes-precedence')
      await runCopyrightizen(tmpDir);

Severity: Major
Found in e2e/scopes.test.ts and 2 other locations - About 4 hrs to fix
e2e/scopes.test.ts on lines 19..29
e2e/unsupported-exts.test.ts on lines 5..15

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

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

  test('should use license text from cli and strategy from config file', async () => {
    const { tmpDir, refDir } = await copyReferenceDirectory('config-precedence/with-cli-and-file-config')
    await runCopyrightizen(tmpDir, [
      '--license-text',
      '"Copyright (c) Humans on Jupiter"'
Severity: Major
Found in e2e/config-precedence.test.ts and 2 other locations - About 3 hrs to fix
e2e/cli.test.ts on lines 106..117
e2e/config-precedence.test.ts on lines 29..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 109.

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

  test('it should use license template from `--license-template-url`', async () => {
    const { tmpDir, refDir } = await copyReferenceDirectory('use-license-tpl-file')
    await runCopyrightizen(tmpDir, [
      '--license-template-url',
      'license.txt'
Severity: Major
Found in e2e/cli.test.ts and 2 other locations - About 3 hrs to fix
e2e/config-precedence.test.ts on lines 16..27
e2e/config-precedence.test.ts on lines 29..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 109.

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

  test('should use license text from cli and strategy from package config', async () => {
    const { tmpDir, refDir } = await copyReferenceDirectory('config-precedence/with-cli-and-file-config')
    await runCopyrightizen(tmpDir, [
      '--license-text',
      '"Copyright (c) Humans on Jupiter"'
Severity: Major
Found in e2e/config-precedence.test.ts and 2 other locations - About 3 hrs to fix
e2e/cli.test.ts on lines 106..117
e2e/config-precedence.test.ts on lines 16..27

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 109.

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

  test('it should only process with specified files', async () => {
    const { tmpDir, refDir } = await copyReferenceDirectory('specified-files')
    await runCopyrightizen(tmpDir, [
      'should-be-updated.js'
    ]);
Severity: Major
Found in e2e/cli.test.ts and 1 other location - About 3 hrs to fix
e2e/cli.test.ts on lines 94..104

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

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

  test('it should only process with specified files from real cmd', async () => {
    const { tmpDir, refDir } = await copyReferenceDirectory('specified-files')
    await execCopyrightizen(tmpDir, [
      'should-be-updated.js'
    ]);
Severity: Major
Found in e2e/cli.test.ts and 1 other location - About 3 hrs to fix
e2e/cli.test.ts on lines 82..92

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

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

function launchCli(argv: string[], cwd?: string) {
  return yargs(argv, cwd)
    .options({
      config: {
        description: 'Use the specific configuration file',
Severity: Minor
Found in lib/cli/launcher.ts - About 2 hrs to fix

    Function run has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function run(config: MergedConfigurationModel) {
      const filesGlobMatchedMap = new Map<string, ScopeNameAndExt>()
      const precedenceScopes = await loadTemplates(excludeNodeModulesForScopes(buildPrecedenceScopes(config)))
      const precedenceScopeMap = precedenceScopes.reduce((result, val) => {
        result.set(val.name, val)
    Severity: Minor
    Found in lib/cli/runner.ts - About 1 hr to fix

      Function launch has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export async function launch(argv: string[], cwd?: string) {
        const cmdApp = launchCli(argv, cwd)
        const cmdOptions = cmdApp.argv
        const pkgJSON = require(path.resolve(__dirname, '../../package.json'))
        const explorer = cosmiconfig(pkgJSON.name)
      Severity: Minor
      Found in lib/cli/launcher.ts - About 1 hr to fix

        Function launch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function launch(argv: string[], cwd?: string) {
          const cmdApp = launchCli(argv, cwd)
          const cmdOptions = cmdApp.argv
          const pkgJSON = require(path.resolve(__dirname, '../../package.json'))
          const explorer = cosmiconfig(pkgJSON.name)
        Severity: Minor
        Found in lib/cli/launcher.ts - About 45 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 removeOldCopyright has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export function removeOldCopyright(source: string, commentRegexp: RegExp, cpRegExp: RegExp) {
          if (cpRegExp.test(source)) {
            let matches
            const existingVersions = []
            const input = source.trim()
        Severity: Minor
        Found in lib/util.ts - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Multiple imports from '../util' can be combined into one.
        Open

        import { blockCommentRegexp } from '../util'
        Severity: Minor
        Found in lib/renderer/js-renderer.ts by tslint

        Rule: no-duplicate-imports

        Disallows multiple import statements from the same module.

        Rationale

        Using a single import statement per module will make the code clearer because you can see everything being imported from that module on one line.

        Config

        "allow-namespace-imports" allows you to import namespaces on separate lines.

        Examples
        "no-duplicate-imports": true,[object Object]
        Schema
        {
          "type": "object",
          "properties": {
            "allow-namespace-imports": {
              "type": "boolean"
            }
          }
        }

        For more information see this page.

        Severity
        Category
        Status
        Source
        Language