polkadot-js/api

View on GitHub
packages/typegen/src/util/formatting.ts

Summary

Maintainability
F
4 days
Test Coverage

formatters has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

const formatters: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => string> = {
  [TypeDefInfo.Compact]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
    return singleParamNotation(registry, 'Compact', typeDef, definitions, imports, withShortcut);
  },

Severity: Minor
Found in packages/typegen/src/util/formatting.ts - About 2 hrs to fix

    Function singleParamNotation has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function singleParamNotation (registry: Registry, wrapper: string, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean): string {
    Severity: Minor
    Found in packages/typegen/src/util/formatting.ts - About 45 mins to fix

      Function dualParamsNotation has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function dualParamsNotation (registry: Registry, wrapper: string, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean): string {
      Severity: Minor
      Found in packages/typegen/src/util/formatting.ts - About 45 mins to fix

        Function formatType has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        export function formatType (registry: Registry, definitions: Record<string, ModuleTypes>, type: AnyString | TypeDef, imports: TypeImports, withShortcut = false): string {
        Severity: Minor
        Found in packages/typegen/src/util/formatting.ts - About 35 mins to fix

          Function exportInterface has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          export function exportInterface (lookupIndex = -1, name = '', base: string, body = '', withShortcut = false): string {
          Severity: Minor
          Found in packages/typegen/src/util/formatting.ts - About 35 mins to fix

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

            export function formatType (registry: Registry, definitions: Record<string, ModuleTypes>, type: AnyString | TypeDef, imports: TypeImports, withShortcut = false): string {
              let typeDef: TypeDef;
            
              if (isString(type)) {
                const _type = type.toString();
            Severity: Minor
            Found in packages/typegen/src/util/formatting.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

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

            export function exportInterface (lookupIndex = -1, name = '', base: string, body = '', withShortcut = false): string {
              // * @description extends [[${base}]]
              const doc = withShortcut
                ? ''
                : `/** @name ${name}${lookupIndex !== -1 ? ` (${lookupIndex})` : ''} */\n`;
            Severity: Minor
            Found in packages/typegen/src/util/formatting.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

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

              [TypeDefInfo.Set]: (_registry: Registry, typeDef: TypeDef, _definitions: Record<string, ModuleTypes>, _imports: TypeImports, _withShortcut: boolean) => {
                throw new Error(`TypeDefInfo.Set: Parameter formatting not implemented on ${stringify(typeDef)}`);
              },
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 2 other locations - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 155..157
            packages/typegen/src/util/formatting.ts on lines 159..161

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

              [TypeDefInfo.Int]: (_registry: Registry, typeDef: TypeDef, _definitions: Record<string, ModuleTypes>, _imports: TypeImports, _withShortcut: boolean) => {
                throw new Error(`TypeDefInfo.Int: Parameter formatting not implemented on ${stringify(typeDef)}`);
              },
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 2 other locations - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 159..161
            packages/typegen/src/util/formatting.ts on lines 187..189

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

              [TypeDefInfo.UInt]: (_registry: Registry, typeDef: TypeDef, _definitions: Record<string, ModuleTypes>, _imports: TypeImports, _withShortcut: boolean) => {
                throw new Error(`TypeDefInfo.UInt: Parameter formatting not implemented on ${stringify(typeDef)}`);
              },
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 2 other locations - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 155..157
            packages/typegen/src/util/formatting.ts on lines 187..189

            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

              [TypeDefInfo.Null]: (_registry: Registry, _typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, _withShortcut: boolean) => {
                setImports(definitions, imports, ['Null']);
            
                return 'Null';
              },
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 1 other location - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 141..145

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

            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

              [TypeDefInfo.DoNotConstruct]: (_registry: Registry, _typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, _withShortcut: boolean) => {
                setImports(definitions, imports, ['DoNotConstruct']);
            
                return 'DoNotConstruct';
              },
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 1 other location - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 163..167

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

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

              [TypeDefInfo.Range]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
                return singleParamNotation(registry, 'Range', typeDef, definitions, imports, withShortcut);
              },
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 11 other locations - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 137..139
            packages/typegen/src/util/formatting.ts on lines 169..171
            packages/typegen/src/util/formatting.ts on lines 183..185
            packages/typegen/src/util/formatting.ts on lines 225..227
            packages/typegen/src/util/formatting.ts on lines 241..243
            packages/typegen/src/util/formatting.ts on lines 245..247
            packages/typegen/src/util/formatting.ts on lines 249..251
            packages/typegen/src/util/formatting.ts on lines 253..255
            packages/typegen/src/util/formatting.ts on lines 257..259
            packages/typegen/src/util/formatting.ts on lines 261..263
            packages/typegen/src/util/formatting.ts on lines 265..267

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

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

              [TypeDefInfo.Linkage]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
                return singleParamNotation(registry, 'Linkage', typeDef, definitions, imports, withShortcut);
              },
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 11 other locations - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 137..139
            packages/typegen/src/util/formatting.ts on lines 169..171
            packages/typegen/src/util/formatting.ts on lines 179..181
            packages/typegen/src/util/formatting.ts on lines 183..185
            packages/typegen/src/util/formatting.ts on lines 225..227
            packages/typegen/src/util/formatting.ts on lines 241..243
            packages/typegen/src/util/formatting.ts on lines 245..247
            packages/typegen/src/util/formatting.ts on lines 249..251
            packages/typegen/src/util/formatting.ts on lines 257..259
            packages/typegen/src/util/formatting.ts on lines 261..263
            packages/typegen/src/util/formatting.ts on lines 265..267

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

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

              [TypeDefInfo.RangeInclusive]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
                return singleParamNotation(registry, 'RangeInclusive', typeDef, definitions, imports, withShortcut);
              },
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 11 other locations - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 137..139
            packages/typegen/src/util/formatting.ts on lines 169..171
            packages/typegen/src/util/formatting.ts on lines 179..181
            packages/typegen/src/util/formatting.ts on lines 225..227
            packages/typegen/src/util/formatting.ts on lines 241..243
            packages/typegen/src/util/formatting.ts on lines 245..247
            packages/typegen/src/util/formatting.ts on lines 249..251
            packages/typegen/src/util/formatting.ts on lines 253..255
            packages/typegen/src/util/formatting.ts on lines 257..259
            packages/typegen/src/util/formatting.ts on lines 261..263
            packages/typegen/src/util/formatting.ts on lines 265..267

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

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

              [TypeDefInfo.WrapperKeepOpaque]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
                return singleParamNotation(registry, 'WrapperKeepOpaque', typeDef, definitions, imports, withShortcut);
              },
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 11 other locations - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 137..139
            packages/typegen/src/util/formatting.ts on lines 169..171
            packages/typegen/src/util/formatting.ts on lines 179..181
            packages/typegen/src/util/formatting.ts on lines 183..185
            packages/typegen/src/util/formatting.ts on lines 225..227
            packages/typegen/src/util/formatting.ts on lines 241..243
            packages/typegen/src/util/formatting.ts on lines 245..247
            packages/typegen/src/util/formatting.ts on lines 249..251
            packages/typegen/src/util/formatting.ts on lines 253..255
            packages/typegen/src/util/formatting.ts on lines 257..259
            packages/typegen/src/util/formatting.ts on lines 265..267

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

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

              [TypeDefInfo.BTreeMap]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
                return dualParamsNotation(registry, 'BTreeMap', typeDef, definitions, imports, withShortcut);
              },
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 11 other locations - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 137..139
            packages/typegen/src/util/formatting.ts on lines 169..171
            packages/typegen/src/util/formatting.ts on lines 179..181
            packages/typegen/src/util/formatting.ts on lines 183..185
            packages/typegen/src/util/formatting.ts on lines 225..227
            packages/typegen/src/util/formatting.ts on lines 245..247
            packages/typegen/src/util/formatting.ts on lines 249..251
            packages/typegen/src/util/formatting.ts on lines 253..255
            packages/typegen/src/util/formatting.ts on lines 257..259
            packages/typegen/src/util/formatting.ts on lines 261..263
            packages/typegen/src/util/formatting.ts on lines 265..267

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

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

              [TypeDefInfo.BTreeSet]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
                return singleParamNotation(registry, 'BTreeSet', typeDef, definitions, imports, withShortcut);
              },
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 11 other locations - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 137..139
            packages/typegen/src/util/formatting.ts on lines 169..171
            packages/typegen/src/util/formatting.ts on lines 179..181
            packages/typegen/src/util/formatting.ts on lines 183..185
            packages/typegen/src/util/formatting.ts on lines 225..227
            packages/typegen/src/util/formatting.ts on lines 241..243
            packages/typegen/src/util/formatting.ts on lines 249..251
            packages/typegen/src/util/formatting.ts on lines 253..255
            packages/typegen/src/util/formatting.ts on lines 257..259
            packages/typegen/src/util/formatting.ts on lines 261..263
            packages/typegen/src/util/formatting.ts on lines 265..267

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

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

              [TypeDefInfo.Compact]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
                return singleParamNotation(registry, 'Compact', typeDef, definitions, imports, withShortcut);
              },
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 11 other locations - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 169..171
            packages/typegen/src/util/formatting.ts on lines 179..181
            packages/typegen/src/util/formatting.ts on lines 183..185
            packages/typegen/src/util/formatting.ts on lines 225..227
            packages/typegen/src/util/formatting.ts on lines 241..243
            packages/typegen/src/util/formatting.ts on lines 245..247
            packages/typegen/src/util/formatting.ts on lines 249..251
            packages/typegen/src/util/formatting.ts on lines 253..255
            packages/typegen/src/util/formatting.ts on lines 257..259
            packages/typegen/src/util/formatting.ts on lines 261..263
            packages/typegen/src/util/formatting.ts on lines 265..267

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

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

              [TypeDefInfo.Option]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
                return singleParamNotation(registry, 'Option', typeDef, definitions, imports, withShortcut);
              },
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 11 other locations - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 137..139
            packages/typegen/src/util/formatting.ts on lines 179..181
            packages/typegen/src/util/formatting.ts on lines 183..185
            packages/typegen/src/util/formatting.ts on lines 225..227
            packages/typegen/src/util/formatting.ts on lines 241..243
            packages/typegen/src/util/formatting.ts on lines 245..247
            packages/typegen/src/util/formatting.ts on lines 249..251
            packages/typegen/src/util/formatting.ts on lines 253..255
            packages/typegen/src/util/formatting.ts on lines 257..259
            packages/typegen/src/util/formatting.ts on lines 261..263
            packages/typegen/src/util/formatting.ts on lines 265..267

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

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

              [TypeDefInfo.HashMap]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
                return dualParamsNotation(registry, 'HashMap', typeDef, definitions, imports, withShortcut);
              },
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 11 other locations - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 137..139
            packages/typegen/src/util/formatting.ts on lines 169..171
            packages/typegen/src/util/formatting.ts on lines 179..181
            packages/typegen/src/util/formatting.ts on lines 183..185
            packages/typegen/src/util/formatting.ts on lines 225..227
            packages/typegen/src/util/formatting.ts on lines 241..243
            packages/typegen/src/util/formatting.ts on lines 245..247
            packages/typegen/src/util/formatting.ts on lines 253..255
            packages/typegen/src/util/formatting.ts on lines 257..259
            packages/typegen/src/util/formatting.ts on lines 261..263
            packages/typegen/src/util/formatting.ts on lines 265..267

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

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

              [TypeDefInfo.WrapperOpaque]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
                return singleParamNotation(registry, 'WrapperOpaque', typeDef, definitions, imports, withShortcut);
              }
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 11 other locations - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 137..139
            packages/typegen/src/util/formatting.ts on lines 169..171
            packages/typegen/src/util/formatting.ts on lines 179..181
            packages/typegen/src/util/formatting.ts on lines 183..185
            packages/typegen/src/util/formatting.ts on lines 225..227
            packages/typegen/src/util/formatting.ts on lines 241..243
            packages/typegen/src/util/formatting.ts on lines 245..247
            packages/typegen/src/util/formatting.ts on lines 249..251
            packages/typegen/src/util/formatting.ts on lines 253..255
            packages/typegen/src/util/formatting.ts on lines 257..259
            packages/typegen/src/util/formatting.ts on lines 261..263

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

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

              [TypeDefInfo.Vec]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
                return singleParamNotation(registry, 'Vec', typeDef, definitions, imports, withShortcut);
              },
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 11 other locations - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 137..139
            packages/typegen/src/util/formatting.ts on lines 169..171
            packages/typegen/src/util/formatting.ts on lines 179..181
            packages/typegen/src/util/formatting.ts on lines 183..185
            packages/typegen/src/util/formatting.ts on lines 241..243
            packages/typegen/src/util/formatting.ts on lines 245..247
            packages/typegen/src/util/formatting.ts on lines 249..251
            packages/typegen/src/util/formatting.ts on lines 253..255
            packages/typegen/src/util/formatting.ts on lines 257..259
            packages/typegen/src/util/formatting.ts on lines 261..263
            packages/typegen/src/util/formatting.ts on lines 265..267

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

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

              [TypeDefInfo.Result]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
                return dualParamsNotation(registry, 'Result', typeDef, definitions, imports, withShortcut);
              },
            Severity: Major
            Found in packages/typegen/src/util/formatting.ts and 11 other locations - About 1 hr to fix
            packages/typegen/src/util/formatting.ts on lines 137..139
            packages/typegen/src/util/formatting.ts on lines 169..171
            packages/typegen/src/util/formatting.ts on lines 179..181
            packages/typegen/src/util/formatting.ts on lines 183..185
            packages/typegen/src/util/formatting.ts on lines 225..227
            packages/typegen/src/util/formatting.ts on lines 241..243
            packages/typegen/src/util/formatting.ts on lines 245..247
            packages/typegen/src/util/formatting.ts on lines 249..251
            packages/typegen/src/util/formatting.ts on lines 253..255
            packages/typegen/src/util/formatting.ts on lines 261..263
            packages/typegen/src/util/formatting.ts on lines 265..267

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

            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

              upper (options: { fn: (self: unknown) => string }) {
                return options.fn(this).toUpperCase();
              }
            Severity: Minor
            Found in packages/typegen/src/util/formatting.ts and 1 other location - About 40 mins to fix
            packages/typegen/src/util/formatting.ts on lines 98..100

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

            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

              trim (options: { fn: (self: unknown) => string }) {
                return options.fn(this).trim();
              },
            Severity: Minor
            Found in packages/typegen/src/util/formatting.ts and 1 other location - About 40 mins to fix
            packages/typegen/src/util/formatting.ts on lines 101..103

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

            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 singleParamNotation (registry: Registry, wrapper: string, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean): string {
              const sub = (typeDef.sub as TypeDef);
            
              setImports(definitions, imports, [wrapper, sub.lookupName]);
            
            
            Severity: Minor
            Found in packages/typegen/src/util/formatting.ts and 1 other location - About 35 mins to fix
            packages/typegen/src/util/formatting.ts on lines 125..134

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

            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 dualParamsNotation (registry: Registry, wrapper: string, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean): string {
              const [a, b] = (typeDef.sub as TypeDef[]);
            
              setImports(definitions, imports, [wrapper, a.lookupName, b.lookupName]);
            
            
            Severity: Minor
            Found in packages/typegen/src/util/formatting.ts and 1 other location - About 35 mins to fix
            packages/typegen/src/util/formatting.ts on lines 117..123

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

            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

            There are no issues that match your filters.

            Category
            Status