jdalrymple/semantic-release-npmx

View on GitHub

Showing 18 of 18 total issues

File npm-utils.js has 427 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import rc from 'rc';
import getAuthToken from 'registry-auth-token';
import { outputFile, readFile } from 'fs-extra';
import { WritableStreamBuffer } from 'stream-buffers';
import { PassThrough } from 'stream';
Severity: Minor
Found in test/unit/npm-utils.js - About 6 hrs to fix

    File publish.js has 354 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import execa from 'execa';
    import { directory as getTempDir } from 'tempy';
    import { outputJson, readJson, pathExists } from 'fs-extra';
    import { WritableStreamBuffer } from 'stream-buffers';
    import path from 'path';
    Severity: Minor
    Found in test/integration/publish.js - About 4 hrs to fix

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

        it('should throw error if "NPM_USERNAME" is missing', async () => {
          getAuthToken.mockReturnValueOnce(false);
          rc.mockReturnValueOnce({ configs: ['/home/.npmrc', '/temp/.npmrc'] });
      
          await expect(
      Severity: Major
      Found in test/unit/npm-utils.js and 2 other locations - About 2 hrs to fix
      test/unit/npm-utils.js on lines 268..282
      test/unit/npm-utils.js on lines 284..298

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

      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('should throw error if "NPM_PASSWORD" is missing', async () => {
          getAuthToken.mockReturnValueOnce(false);
          rc.mockReturnValueOnce({ configs: ['/home/.npmrc', '/temp/.npmrc'] });
      
          await expect(
      Severity: Major
      Found in test/unit/npm-utils.js and 2 other locations - About 2 hrs to fix
      test/unit/npm-utils.js on lines 252..266
      test/unit/npm-utils.js on lines 284..298

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

      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('should throw error if "NPM_EMAIL" is missing', async () => {
          getAuthToken.mockReturnValueOnce(false);
          rc.mockReturnValueOnce({ configs: ['/home/.npmrc', '/temp/.npmrc'] });
      
          await expect(
      Severity: Major
      Found in test/unit/npm-utils.js and 2 other locations - About 2 hrs to fix
      test/unit/npm-utils.js on lines 252..266
      test/unit/npm-utils.js on lines 268..282

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

      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('should throw SemanticReleaseError if "npmPublish" option is not a Boolean', () => {
          const npmPublish = 42;
          const error = new AggregateError([getError('EINVALIDNPMPUBLISH')]);
      
          try {
      Severity: Major
      Found in test/unit/plugin-config.js and 2 other locations - About 1 hr to fix
      test/unit/plugin-config.js on lines 28..38
      test/unit/plugin-config.js on lines 40..50

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

      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('should throw SemanticReleaseError if "pkgRoot" option is not a String', async () => {
          const pkgRoot = 42;
          const error = new AggregateError([getError('EINVALIDPKGROOT')]);
      
          try {
      Severity: Major
      Found in test/unit/plugin-config.js and 2 other locations - About 1 hr to fix
      test/unit/plugin-config.js on lines 16..26
      test/unit/plugin-config.js on lines 28..38

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

      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('should throw SemanticReleaseError if "tarballDir" option is not a String', async () => {
          const tarballDir = 42;
          const error = new AggregateError([getError('EINVALIDTARBALLDIR')]);
      
          try {
      Severity: Major
      Found in test/unit/plugin-config.js and 2 other locations - About 1 hr to fix
      test/unit/plugin-config.js on lines 16..26
      test/unit/plugin-config.js on lines 40..50

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

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

          await expect(
            execa('npm', ['view', pkg.name, 'dist-tags.latest'], {
              cwd,
              env: { ...process.env, npm_config_registry: process.env.TEST_NPM_REGISTRY },
            }),
      Severity: Major
      Found in test/integration/e2e.js and 7 other locations - About 40 mins to fix
      test/integration/e2e.js on lines 90..97
      test/integration/e2e.js on lines 133..140
      test/integration/e2e.js on lines 150..157
      test/integration/publish.js on lines 49..56
      test/integration/publish.js on lines 89..96
      test/integration/publish.js on lines 128..135
      test/integration/publish.js on lines 339..346

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

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

          await expect(
            execa('npm', ['view', pkg.name, 'dist-tags.latest'], {
              cwd,
              env: { ...process.env, npm_config_registry: process.env.TEST_NPM_REGISTRY },
            }),
      Severity: Major
      Found in test/integration/e2e.js and 7 other locations - About 40 mins to fix
      test/integration/e2e.js on lines 49..56
      test/integration/e2e.js on lines 90..97
      test/integration/e2e.js on lines 133..140
      test/integration/publish.js on lines 49..56
      test/integration/publish.js on lines 89..96
      test/integration/publish.js on lines 128..135
      test/integration/publish.js on lines 339..346

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

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

          await expect(
            execa('npm', ['view', subpkg.name, 'version'], {
              cwd,
              env: { ...process.env, npm_config_registry: process.env.TEST_NPM_REGISTRY },
            }),
      Severity: Major
      Found in test/integration/publish.js and 7 other locations - About 40 mins to fix
      test/integration/e2e.js on lines 49..56
      test/integration/e2e.js on lines 90..97
      test/integration/e2e.js on lines 133..140
      test/integration/e2e.js on lines 150..157
      test/integration/publish.js on lines 49..56
      test/integration/publish.js on lines 89..96
      test/integration/publish.js on lines 128..135

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

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

          await expect(
            execa('npm', ['view', pkg.name, 'version'], {
              cwd,
              env: { ...process.env, npm_config_registry: process.env.TEST_NPM_REGISTRY },
            }),
      Severity: Major
      Found in test/integration/publish.js and 7 other locations - About 40 mins to fix
      test/integration/e2e.js on lines 49..56
      test/integration/e2e.js on lines 90..97
      test/integration/e2e.js on lines 133..140
      test/integration/e2e.js on lines 150..157
      test/integration/publish.js on lines 49..56
      test/integration/publish.js on lines 128..135
      test/integration/publish.js on lines 339..346

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

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

          await expect(
            execa('npm', ['view', pkg.name, 'version'], {
              cwd,
              env: { ...process.env, npm_config_registry: process.env.TEST_NPM_REGISTRY },
            }),
      Severity: Major
      Found in test/integration/publish.js and 7 other locations - About 40 mins to fix
      test/integration/e2e.js on lines 49..56
      test/integration/e2e.js on lines 90..97
      test/integration/e2e.js on lines 133..140
      test/integration/e2e.js on lines 150..157
      test/integration/publish.js on lines 49..56
      test/integration/publish.js on lines 89..96
      test/integration/publish.js on lines 339..346

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

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

          await expect(
            execa('npm', ['view', pkg.name, 'dist-tags.next'], {
              cwd,
              env: { ...process.env, npm_config_registry: process.env.TEST_NPM_REGISTRY },
            }),
      Severity: Major
      Found in test/integration/e2e.js and 7 other locations - About 40 mins to fix
      test/integration/e2e.js on lines 49..56
      test/integration/e2e.js on lines 90..97
      test/integration/e2e.js on lines 150..157
      test/integration/publish.js on lines 49..56
      test/integration/publish.js on lines 89..96
      test/integration/publish.js on lines 128..135
      test/integration/publish.js on lines 339..346

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

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

          await expect(
            execa('npm', ['view', pkg.name, 'version'], {
              cwd,
              env: { ...process.env, npm_config_registry: process.env.TEST_NPM_REGISTRY },
            }),
      Severity: Major
      Found in test/integration/publish.js and 7 other locations - About 40 mins to fix
      test/integration/e2e.js on lines 49..56
      test/integration/e2e.js on lines 90..97
      test/integration/e2e.js on lines 133..140
      test/integration/e2e.js on lines 150..157
      test/integration/publish.js on lines 89..96
      test/integration/publish.js on lines 128..135
      test/integration/publish.js on lines 339..346

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

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

          await expect(
            execa('npm', ['view', pkg.name, 'dist-tags'], {
              cwd,
              env: { ...process.env, npm_config_registry: process.env.TEST_NPM_REGISTRY },
            }),
      Severity: Major
      Found in test/integration/e2e.js and 7 other locations - About 40 mins to fix
      test/integration/e2e.js on lines 49..56
      test/integration/e2e.js on lines 133..140
      test/integration/e2e.js on lines 150..157
      test/integration/publish.js on lines 49..56
      test/integration/publish.js on lines 89..96
      test/integration/publish.js on lines 128..135
      test/integration/publish.js on lines 339..346

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

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

      export async function setAuth(
        npmrc,
        registry,
        { cwd = '.', env: { NPM_TOKEN, NPM_EMAIL, NPM_CONFIG_USERCONFIG, LEGACY_TOKEN } = {}, logger },
      ) {
      Severity: Minor
      Found in src/npm-utils.js - 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

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

      export async function publishNpm(
        npmrc,
        context,
        { npmPublish, pkgRoot, access = 'restricted' },
        pkgJson,
      Severity: Minor
      Found in src/publish-utils.js - 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

      Severity
      Category
      Status
      Source
      Language