vincent-ledu/vscode-adr-tools-extension

View on GitHub

Showing 12 of 12 total issues

Function adrNew has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function adrNew () {
  let adrAttr = {}
  const rootPath = vscode.workspace.rootPath
  let adrFolder = path.join(
    rootPath,
Severity: Major
Found in ui/commands.js - About 2 hrs to fix

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

    function getTitle (adrDir, file) {
      let data = fs.readFileSync(path.join(adrDir, file), 'utf8')
      let res = data.match(/^#[ \t]*\d+[ \t]*\.([ \t\w,-]*)$/m)
      if (res.length === 2) {
        return res[1].trim()
    Severity: Major
    Found in parsing/parsingAdr.js and 1 other location - About 2 hrs to fix
    parsing/parsingAdr.js on lines 23..29

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

    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

    function getStatusSection (adrDir, file) {
      let data = fs.readFileSync(path.join(adrDir, file), 'utf8')
      let res = data.match(/^## Status\s*([\w\W]*)^## Context/m)
      if (res.length === 2) {
        return res[1].trim()
    Severity: Major
    Found in parsing/parsingAdr.js and 1 other location - About 2 hrs to fix
    parsing/parsingAdr.js on lines 10..16

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

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

    async function adrInit () {
      let configuredAdrProjectDirectory = path.normalize(vscode.workspace.getConfiguration().get('adr.project.directory'))
      const adrProjectDirectory = await vscode.window
        .showInputBox({
          value: configuredAdrProjectDirectory,
    Severity: Minor
    Found in ui/commands.js - About 1 hr to fix

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

      function adrLink () {
        let adrFolder = path.join(vscode.workspace.rootPath, vscode.workspace.getConfiguration().get('adr.project.directory'))
        vscode.window
          .showQuickPick(adrUtils.getAllAdr(adrFolder), {
            prompt: 'Enter source ADR name',
      Severity: Minor
      Found in ui/commands.js - About 1 hr to fix

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

        function adrGenerateDocs () {
          logger.vsLog('entering generate docs')
          let adrFolder = path.join(vscode.workspace.rootPath, vscode.workspace.getConfiguration().get('adr.project.directory'))
          let adrs = adrUtils.getAllAdr(adrFolder)
          graph.deleteGraph(adrFolder)
        Severity: Minor
        Found in ui/commands.js - About 1 hr to fix

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

          async function adrNew () {
            let adrAttr = {}
            const rootPath = vscode.workspace.rootPath
            let adrFolder = path.join(
              rootPath,
          Severity: Minor
          Found in ui/commands.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 createNewAdr has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function createNewAdr (adrAttr, adrPath, adrTemplatePath, useTimestampPrefix) {
            logger.vsLog(
              `create new adr ${adrAttr.srcAdrName}  in  ${adrPath} from templatepath  ${adrTemplatePath} useTimstampForFilePrefix: ${useTimestampPrefix} `
            )
            const prefix = getPrefix(adrPath, useTimestampPrefix)
          Severity: Minor
          Found in adrfunc/adr-utils.js - About 1 hr to fix

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

            function createNode (adrDir, index, filename, title, date, status) {
            Severity: Minor
            Found in reports/graph.js - About 45 mins to fix

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

              function addLink (adrDir, indexSrc, indexDst, link, date) {
              Severity: Minor
              Found in reports/graph.js - About 35 mins to fix

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

                function getGraph (adrDir) {
                  let data
                  try {
                    data = fs.readFileSync(path.join(adrDir, graphFile))
                  } catch (err) {
                Severity: Minor
                Found in reports/graph.js - 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

                Avoid too many return statements within this function.
                Open

                    if (!tgtAdrName) return
                Severity: Major
                Found in ui/commands.js - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language