john-goldsmith/vscode-aws-cloudformation-auto-template-generator

View on GitHub

Showing 7 of 23 total issues

Function getTemplate has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

export default function getTemplate(schema: ResourceTypeSchema, logicalId = getLogicalId(schema.typeName)): Template {
  const readOnlyProperties = schema.readOnlyProperties.map(property => {
    const pieces = property.split('/')
    return pieces[pieces.length - 1]
  })
Severity: Minor
Found in src/utils/get-template.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 insertResource has 114 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function insertResource(context: ExtensionContext) {
  return async (): Promise<void> => {
    try {
      const { activeTextEditor } = window
      if (!activeTextEditor) throw new NoActiveTextEditorError()
Severity: Major
Found in src/commands/insert-resource.ts - About 4 hrs to fix

    Function getTemplate has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function getTemplate(schema: ResourceTypeSchema, logicalId = getLogicalId(schema.typeName)): Template {
      const readOnlyProperties = schema.readOnlyProperties.map(property => {
        const pieces = property.split('/')
        return pieces[pieces.length - 1]
      })
    Severity: Major
    Found in src/utils/get-template.ts - About 2 hrs to fix

      Function getProperties has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function getProperties(key: string, value: ResourceProperties, template: Template['key']['Properties'] | unknown[]) {
      
          if (value['$ref']) {
            const definitionPieces = value['$ref'].split('/')
            const definitionKey = definitionPieces[definitionPieces.length - 1]
      Severity: Major
      Found in src/utils/get-template.ts - About 2 hrs to fix

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

        export default function normalizeConfigFile(data: ParsedIniData): ParsedIniData {
          const map: ParsedIniData = {}
          for (const key of Object.keys(data)) {
            if (key === 'default') {
              map.default = data.default
        Severity: Minor
        Found in src/utils/normalize-config-file.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 setConfigFilePath has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function setConfigFilePath() {
          return async (): Promise<void> => {
            try {
              const workspaceConfiguration = getConfiguration(EXTENSION_NAME)
              let configFilePath = await workspaceConfiguration.get<string>(CONFIG_FILE_PATH_CONFIGURATION_PROPERTY)
        Severity: Minor
        Found in src/commands/set-config-file-path.ts - About 1 hr to fix

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

          export default function parseIni(iniData: string): ParsedIniData {
            const map: ParsedIniData = {}
            let currentSection: string | undefined
            for (let line of iniData.split(/\r?\n/)) {
              line = line.split(/(^|\s)[;#]/)[0] // remove comments
          Severity: Minor
          Found in src/utils/parse-ini.ts - About 45 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