vgno/roc-config

View on GitHub

Showing 571 of 571 total issues

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

        it('should manage if the selected extension has no hooks and give suggestion', () => {
            expect(() => runHook('roc-package-a')('hook-name'))
                .toThrow(/process exit/);
            expect(stripAnsi(logErrorSpy.calls[0].arguments[0]))
                .toMatch(/Did not understand roc-package-a - Did you mean roc-package-b/);
Severity: Major
Found in test/hooks/runHook.js and 1 other location - About 1 hr to fix
test/hooks/runHook.js on lines 43..48

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

        it('should manage if the selected extension has no matching hook and give suggestion', () => {
            expect(() => runHook('roc-package-b')('hook-name-c'))
                .toThrow(/process exit/);
            expect(stripAnsi(logErrorSpy.calls[0].arguments[0]))
                .toMatch(/Did not understand hook-name-c - Did you mean hook-name-a/);
Severity: Major
Found in test/hooks/runHook.js and 1 other location - About 1 hr to fix
test/hooks/runHook.js on lines 36..41

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

Function validateCommands has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export function validateCommands(name, extensionCommands, stateCommands, ignoreExtension = false) {
    const getKeys = (obj, state = {}, isState = false, oldPath = '', allKeys = []) => {
        Object.keys(obj).forEach((key) => {
            const value = obj[key];
            const newPath = oldPath + key;
Severity: Minor
Found in src/context/extensions/helpers/processCommands.js - 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

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

function notInExtensions(extensions, extension) {
    if (Array.isArray(extension)) {
        return !extension.some((e) => extensions.indexOf(e) !== -1);
    }

Severity: Major
Found in src/context/extensions/helpers/processConfig.js and 1 other location - About 1 hr to fix
src/context/extensions/helpers/processCommands.js on lines 78..84

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

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

function notInExtensions(extensions, extension) {
    if (Array.isArray(extension)) {
        return !extension.some((e) => extensions.indexOf(e) !== -1);
    }

Severity: Major
Found in src/context/extensions/helpers/processCommands.js and 1 other location - About 1 hr to fix
src/context/extensions/helpers/processConfig.js on lines 98..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 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 2 locations. Consider refactoring.
Open

    const table = generateTable(body, newHeader, {
        groupTitleWrapper: (groupName, level2) => `${pad(level2 + 3, '#')} ${
            groupName.charAt(0).toUpperCase() + groupName.slice(1)}`,
    });
Severity: Major
Found in src/documentation/markdown/commandsToMarkdown.js and 1 other location - About 1 hr to fix
src/documentation/markdown/settingsToMarkdown.js on lines 60..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 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 2 locations. Consider refactoring.
Open

    const settingsTable = generateTable(documentationObject, header, {
        groupTitleWrapper: (title, level) => `${pad(level + 2, '#')} ${title.charAt(0).toUpperCase() + title.slice(1)}`,
    });
Severity: Major
Found in src/documentation/markdown/settingsToMarkdown.js and 1 other location - About 1 hr to fix
src/documentation/markdown/commandsToMarkdown.js on lines 278..281

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

export function validateCommands(name, extensionCommands, stateCommands, ignoreExtension = false) {
    const getKeys = (obj, state = {}, isState = false, oldPath = '', allKeys = []) => {
        Object.keys(obj).forEach((key) => {
            const value = obj[key];
            const newPath = oldPath + key;
Severity: Minor
Found in src/context/extensions/helpers/processCommands.js - About 1 hr to fix

    Function validateRocExtension has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function validateRocExtension(path) {
        return (roc, state) => {
            if (!roc.name || !roc.version) {
                throw new ExtensionError(
                    `Will ignore the extension. Expected it to have a ${underline('name')} and ` +
    Severity: Minor
    Found in src/context/extensions/steps/getExtensions.js - About 1 hr to fix

      Function actionsToMarkdown has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function actionsToMarkdown(name, actions = [], mode, project) {
          // Remove project actions if we are not in project mode
          const correctedActions = !project ?
              actions.filter((extensionActions) => !extensionActions.project) :
              actions;
      Severity: Minor
      Found in src/documentation/markdown/actionsToMarkdown.js - About 1 hr to fix

        Function normalizeCommands has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function normalizeCommands(name, path, extensionCommands, stateCommands = {}) {
            const normalizeCommandsHelper = (newCommands, existingCommands = {}, oldPath = '') => {
                const localCommands = { ...newCommands };
                Object.keys(localCommands).forEach((command) => {
                    const newPath = oldPath + command;
        Severity: Minor
        Found in src/context/extensions/helpers/processCommands.js - About 1 hr to fix

          Function getProjectConfig has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function getProjectConfig(projectConfigPath, directory = process.cwd(), verbose = false) {
              if (projectConfigPath === false) {
                  return {};
              }
          
          
          Severity: Minor
          Found in src/configuration/getProjectConfig.js - 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 github has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          async function github(template, version) {
              // Temporary to get next for the moment
              if (!version) {
                  version = defaultVersion; // eslint-disable-line
                  log.info(`Will use ${chalk.bold(version)} as default version`);
          Severity: Minor
          Found in src/commands/init/fetchTemplate.js - 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

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

                  beforeEach(() => {
                      logErrorSpy = spyOn(require('../../src/log/default/large').default, 'error') // eslint-disable-line
                          .andThrow(new Error('Process exit'));
          
                      logWarningSpy = spyOn(require('../../src/log/default/large').default, 'warn'); // eslint-disable-line
          Severity: Major
          Found in test/configuration/getProjectConfig.js and 2 other locations - About 1 hr to fix
          test/configuration/manageConfig.js on lines 16..21
          test/configuration/manageSettings.js on lines 16..21

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

          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

                  beforeEach(() => {
                      logErrorSpy = spyOn(require('../../src/log/default/large').default, 'error') // eslint-disable-line
                          .andThrow(new Error('Process exit'));
          
                      logInfoSpy = spyOn(require('../../src/log/default/large').default, 'info'); // eslint-disable-line
          Severity: Major
          Found in test/configuration/manageConfig.js and 2 other locations - About 1 hr to fix
          test/configuration/getProjectConfig.js on lines 13..18
          test/configuration/manageSettings.js on lines 16..21

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

          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

                  beforeEach(() => {
                      logErrorSpy = spyOn(require('../../src/log/default/large').default, 'error') // eslint-disable-line
                          .andThrow(new Error('Process exit'));
          
                      logInfoSpy = spyOn(require('../../src/log/default/large').default, 'info'); // eslint-disable-line
          Severity: Major
          Found in test/configuration/manageSettings.js and 2 other locations - About 1 hr to fix
          test/configuration/getProjectConfig.js on lines 13..18
          test/configuration/manageConfig.js on lines 16..21

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

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

          function mergeState(name) {
              return (previousState, state) => {
                  let temp = {
                      context: {
                          actions: [].concat(previousState.context.actions),
          Severity: Minor
          Found in src/context/extensions/steps/getExtensions.js - About 1 hr to fix

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

            export default function isFunction(value, info) {
                if (info) {
                    return createInfoObject({ validator: 'Function' });
                }
            
            
            Severity: Major
            Found in src/validation/validators/isFunction.js and 1 other location - About 1 hr to fix
            src/validation/validators/isPromise.js on lines 12..24

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

            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

            export default function isPromise(value, info) {
                if (info) {
                    return createInfoObject({
                        validator: 'Promise',
                    });
            Severity: Major
            Found in src/validation/validators/isPromise.js and 1 other location - About 1 hr to fix
            src/validation/validators/isFunction.js on lines 12..22

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

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

            export default function verifyRequiredDependencies(directory, required) {
                const mismatches = verifyInstalledDependencies(directory, required);
                if (mismatches.length > 0) {
                    const header = {
                        name: {
            Severity: Minor
            Found in src/context/dependencies/verifyRequiredDependencies.js - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language