JamieMason/syncpack

View on GitHub

Showing 27 of 63 total issues

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

export function listMismatches(ctx: Syncpack.Ctx): Syncpack.Ctx {
  const hasUserGroups = ctx.versionGroups.length > 1;

  ctx.versionGroups.forEach((versionGroup, i) => {
    const invalidGroups: InstanceGroup[] =
Severity: Major
Found in src/bin-list-mismatches/list-mismatches.ts - About 4 hrs to fix

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

    export function list(ctx: Syncpack.Ctx): Syncpack.Ctx {
      const hasUserGroups = ctx.versionGroups.length > 1;
    
      ctx.versionGroups.forEach((versionGroup, i) => {
        const instanceGroups = versionGroup.getAllInstanceGroups();
    Severity: Major
    Found in src/bin-list/list.ts - About 2 hrs to fix

      Function unSafeGetConfig has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function unSafeGetConfig(
        disk: Disk,
        fromCli: Partial<Syncpack.Config.Cli>,
      ): Syncpack.Config.Private {
        verbose('cli arguments:', fromCli);
      Severity: Minor
      Found in src/get-context/get-config/index.ts - About 1 hr to fix

        Function getPatterns has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function getPatterns(disk: Disk) {
          return function getPatterns(
            program: Syncpack.Config.SyncpackRc,
          ): R.Result<string[], BaseError> {
            type PatternResult = R.Result<string[], BaseError>;
        Severity: Minor
        Found in src/get-context/get-package-json-files/get-patterns/index.ts - About 1 hr to fix

          Function unsafeGetGroups has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function unsafeGetGroups(
            config: Syncpack.Config.Private,
            packageJsonFiles: PackageJsonFile[],
          ): GroupsByPropName {
            type Key = keyof typeof groupsByName;
          Severity: Minor
          Found in src/get-context/get-groups/index.ts - About 1 hr to fix

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

              return function getPatterns(
                program: Syncpack.Config.SyncpackRc,
              ): R.Result<string[], BaseError> {
                type PatternResult = R.Result<string[], BaseError>;
                type SafeGetPatterns = () => PatternResult;
            Severity: Minor
            Found in src/get-context/get-package-json-files/get-patterns/index.ts - About 1 hr to fix

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

              export function format(ctx: Syncpack.Ctx): Syncpack.Ctx {
                const { packageJsonFiles } = ctx;
                const { sortAz, sortFirst } = ctx.config;
              
                packageJsonFiles.forEach((packageJsonFile) => {
              Severity: Minor
              Found in src/bin-format/format.ts - About 1 hr to fix

                Function getLowestVersion has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                export function getLowestVersion(
                  versions: string[],
                ): R.Result<string, BaseError> {
                  let lowest: LowestVersion | undefined;
                
                

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

                  setVersion(version: string | Delete): void {
                    const strategyName = this.pathDef.strategy;
                    const entry: Entry = [this.name, version === DELETE ? undefined : version];
                    const file = this.packageJsonFile;
                    switch (strategyName) {

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

                  export function fixMismatches(ctx: Syncpack.Ctx): Syncpack.Ctx {
                    ctx.versionGroups.forEach((versionGroup) => {
                      const invalidGroups = versionGroup.getInvalidInstanceGroups();
                  
                      // Nothing to do if there are no mismatches
                  Severity: Minor
                  Found in src/bin-fix-mismatches/fix-mismatches.ts - About 1 hr to fix

                    Function getFilePaths has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function getFilePaths(
                      disk: Disk,
                      program: Syncpack.Config.SyncpackRc,
                    ): SafeFilePaths {
                      return pipe(program, getPatterns(disk), R.flatMap(resolvePatterns));
                    Severity: Minor
                    Found in src/get-context/get-package-json-files/get-file-paths.ts - About 1 hr to fix

                      Function write has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        write(file, pathDef, [, version]) {
                          const { contents, shortPath } = file;
                          const isNestedPath = pathDef.path.includes('.');
                          if (isNestedPath) {
                            const fullPath = pathDef.path.split('.');
                      Severity: Minor
                      Found in src/get-context/get-config/path-strategy/version-string.ts - About 1 hr to fix

                        Function write has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          write(file, pathDef, [, version]) {
                            const { contents, shortPath } = file;
                            const isNestedPath = pathDef.path.includes('.');
                        
                            if (isNestedPath) {
                        Severity: Minor
                        Found in src/get-context/get-config/path-strategy/name-and-version-props.ts - About 1 hr to fix

                          Function write has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            write(file, pathDef, [name, version]) {
                              const { contents, shortPath } = file;
                              const isNestedPath = pathDef.path.includes('.');
                              if (isNestedPath) {
                                const fullPath = pathDef.path.split('.');
                          Severity: Minor
                          Found in src/get-context/get-config/path-strategy/name-and-version-string.ts - About 1 hr to fix

                            Function getExpectedVersion has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              getExpectedVersion(): R.Result<string | Delete, BaseError> {
                                const versionGroup = this.versionGroup;
                                if (versionGroup.isBanned()) return R.Ok(DELETE);
                                if (versionGroup.isUnpinned())
                                  return pipe(
                            Severity: Minor
                            Found in src/get-context/get-groups/version-group/instance-group/index.ts - About 1 hr to fix

                              Function showHelpOnError has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export function showHelpOnError(program: Command) {
                                program.showHelpAfterError(chalk`
                              1. The following options were replaced in syncpack@9.0.0:
                              {red
                                -p, --prod              include dependencies
                              Severity: Minor
                              Found in src/lib/show-help-on-error.ts - About 1 hr to fix

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

                                export function getHighestVersion(
                                  versions: string[],
                                ): R.Result<string, BaseError> {
                                  let highest: HighestVersion | undefined;
                                
                                

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

                                export function props<T>(
                                  keys: string,
                                  predicate: (value: unknown) => value is T,
                                ) {
                                  return function getNestedProp(obj: unknown): O.Option<T> {
                                Severity: Minor
                                Found in src/get-context/get-package-json-files/get-patterns/props.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

                                Function onlyOk has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  onlyOk<Input, Output = Input>(
                                    getResult: (value: Input) => R.Result<Output, BaseError>,
                                  ) {
                                    return (inputs: Input[]): R.Result<Output[], BaseError> => {
                                      const outputs: Output[] = [];
                                Severity: Minor
                                Found in src/get-context/$R.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

                                Function getExpectedVersion has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  getExpectedVersion(): R.Result<string | Delete, BaseError> {
                                    const versionGroup = this.versionGroup;
                                    if (versionGroup.isBanned()) return R.Ok(DELETE);
                                    if (versionGroup.isUnpinned())
                                      return pipe(
                                Severity: Minor
                                Found in src/get-context/get-groups/version-group/instance-group/index.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