Ikagaka/sakurascript

View on GitHub

Showing 4 of 41 total issues

File sakurascript.ts has 970 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const splitargs = (str: string) =>
  str
    .replace(/"((?:\\\\|\\"|[^"])*)"/g, (_, quoted) => quoted.replace(/,/g, "\0"))
    .split(/\s*,\s*/)
    .map(arg => arg.replace(/\0/g, ",").replace(/\\(.)/, "$1"));
Severity: Major
Found in lib/sakurascript.ts - About 2 days to fix

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

          match: group => {
            const useClass = group[1] ? SakuraScriptToken.MoveAsync : SakuraScriptToken.Move;
            const args = splitargs(group[2]);
            if (/^--/.test(args[0])) {
              // new
    Severity: Minor
    Found in lib/sakurascript.ts - About 1 hr to fix

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

            match: group => {
              const useClass = group[1] ? SakuraScriptToken.MoveAsync : SakuraScriptToken.Move;
              const args = splitargs(group[2]);
              if (/^--/.test(args[0])) {
                // new
      Severity: Minor
      Found in lib/sakurascript.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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        static parse(script: string) {
          const tokens: SakuraScriptToken[] = [];
          while (script.length) {
            for (const tag of SakuraScript.tagMatchers) {
              if (tag.re.test(script)) {
      Severity: Minor
      Found in lib/sakurascript.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

      Severity
      Category
      Status
      Source
      Language