JamieMason/syncpack

View on GitHub

Showing 24 of 436 total issues

Function getInstances has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

export function getInstances(
  options: SyncpackConfig,
  wrappers: SourceWrapper[],
): Instances {
  const allInstances: Instances = {
Severity: Minor
Found in src/lib/get-input/get-instances.ts - About 6 hrs 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 getConfig has 125 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const getConfig = (
  disk: Disk,
  program: Partial<SyncpackConfig & { configPath: string | undefined }>,
): SyncpackConfig => {
  type OptionName = keyof SyncpackConfig;
Severity: Major
Found in src/lib/get-input/get-config.ts - About 5 hrs to fix

    Function getConfig has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    export const getConfig = (
      disk: Disk,
      program: Partial<SyncpackConfig & { configPath: string | undefined }>,
    ): SyncpackConfig => {
      type OptionName = keyof SyncpackConfig;
    Severity: Minor
    Found in src/lib/get-input/get-config.ts - About 3 hrs 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 getInstances has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function getInstances(
      options: SyncpackConfig,
      wrappers: SourceWrapper[],
    ): Instances {
      const allInstances: Instances = {
    Severity: Major
    Found in src/lib/get-input/get-instances.ts - About 3 hrs to fix

      File get-input.spec.ts has 259 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import 'expect-more-jest';
      import { join } from 'path';
      import { getInput } from '.';
      import { mockDisk } from '../../../test/mock-disk';
      import { CWD, DEFAULT_CONFIG } from '../../constants';
      Severity: Minor
      Found in src/lib/get-input/get-input.spec.ts - About 2 hrs to fix

        Function createScenario has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function createScenario(
          fileMocks: {
            path: string;
            before: SourceWrapper;
            after: SourceWrapper;
        Severity: Major
        Found in test/scenarios/create-scenario.ts - About 2 hrs to fix

          Function listMismatches has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function listMismatches(input: ProgramInput, disk: Disk): void {
            let isInvalid = false;
          
            /**
             * Reverse the list so the default/ungrouped version group is rendered first
          Severity: Minor
          Found in src/bin-list-mismatches/list-mismatches.ts - About 2 hrs to fix

            Function fixMismatches has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function fixMismatches(input: ProgramInput, disk: Disk): void {
              /**
               * Reverse the list so the default/ungrouped version group is rendered first
               * (appears at the top). The actual version groups which the user configured
               * will then start from index 1.
            Severity: Minor
            Found in src/bin-fix-mismatches/fix-mismatches.ts - About 1 hr to fix

              Function format has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function format(input: ProgramInput, disk: Disk): void {
                const { indent, sortAz, sortFirst, wrappers } = input;
              
                wrappers.forEach(({ contents, filePath, json }) => {
                  const sortedKeys = Object.keys(contents).sort();
              Severity: Minor
              Found in src/bin-format/format.ts - About 1 hr to fix

                Function dependentDoesNotMatchNestedWorkspaceVersion has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  dependentDoesNotMatchNestedWorkspaceVersion() {
                    return createScenario(
                      [
                        {
                          path: 'workspaces/a/packages/a/package.json',
                Severity: Minor
                Found in test/scenarios/index.ts - About 1 hr to fix

                  Function semverRangesDoNotMatchConfig has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    semverRangesDoNotMatchConfig() {
                      return createScenario(
                        [
                          {
                            path: 'packages/a/package.json',
                  Severity: Minor
                  Found in test/scenarios/index.ts - About 1 hr to fix

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

                    export function list(input: ProgramInput, disk: Disk): void {
                      let isInvalid = false;
                    
                      /**
                       * Reverse the list so the default/ungrouped version group is rendered first
                    Severity: Minor
                    Found in src/bin-list/list.ts - About 1 hr to fix

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

                      function getRangeScore(version: string): number {
                        if (version === '') return 0;
                        if (version === RANGE_ANY) return 8;
                        const range = getRange(version);
                        if (range === RANGE_GT) return 7;
                      Severity: Minor
                      Found in src/bin-fix-mismatches/get-expected-version/get-highest-version.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 mockedFiles has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        const mockedFiles: MockedFile[] = fileMocks.map((file) => {
                          const absolutePath = join(CWD, file.path);
                          const relativePath = normalize(file.path);
                          return {
                            absolutePath,
                      Severity: Minor
                      Found in test/scenarios/create-scenario.ts - About 1 hr to fix

                        Function mockPackage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export const mockPackage = (
                          dirName: string,
                          {
                            deps,
                            devDeps,
                        Severity: Minor
                        Found in test/mock.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

                        Avoid too many return statements within this function.
                        Open

                          if (range === RANGE_MINOR) return 5;
                        Severity: Major
                        Found in src/bin-fix-mismatches/get-expected-version/get-highest-version.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                            if (range === RANGE_LTE) return 1;
                          Severity: Major
                          Found in src/bin-fix-mismatches/get-expected-version/get-highest-version.ts - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                  return raw;
                            Severity: Major
                            Found in src/bin-fix-mismatches/get-expected-version/get-highest-version.ts - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                  return rawHighest;
                              Severity: Major
                              Found in src/bin-fix-mismatches/get-expected-version/get-highest-version.ts - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                  if (range === RANGE_LT) return 0;
                                Severity: Major
                                Found in src/bin-fix-mismatches/get-expected-version/get-highest-version.ts - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language