FarmBot/Farmbot-Web-App

View on GitHub
frontend/util/version.ts

Summary

Maintainability
B
6 hrs
Test Coverage

Function semverCompare has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export function semverCompare(left: string, right: string): SemverResult {
  const leftSemVer = left.split("-")[0];
  const rightSemVer = right.split("-")[0];
  const leftHasSuffix = left.includes("-");
  const rightHasSuffix = right.includes("-");
Severity: Minor
Found in frontend/util/version.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 semverCompare has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function semverCompare(left: string, right: string): SemverResult {
  const leftSemVer = left.split("-")[0];
  const rightSemVer = right.split("-")[0];
  const leftHasSuffix = left.includes("-");
  const rightHasSuffix = right.includes("-");
Severity: Minor
Found in frontend/util/version.ts - About 1 hr to fix

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

    export function determineInstalledOsVersion(
      bot: BotState, device: TaggedDevice | undefined): string | undefined {
      const fromBotState = bot.hardware.informational_settings.controller_version;
      const fromAPI = device ? device.body.fbos_version : undefined;
      if (isUndefined(fromBotState) && isUndefined(fromAPI)) { return undefined; }
    Severity: Minor
    Found in frontend/util/version.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

    Avoid too many return statements within this function.
    Open

        return SemverResult.RIGHT_IS_GREATER;
    Severity: Major
    Found in frontend/util/version.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return SemverResult.LEFT_IS_GREATER;
      Severity: Major
      Found in frontend/util/version.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

          return SemverResult.EQUAL;
        Severity: Major
        Found in frontend/util/version.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return SemverResult.LEFT_IS_GREATER;
          Severity: Major
          Found in frontend/util/version.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return SemverResult.RIGHT_IS_GREATER;
            Severity: Major
            Found in frontend/util/version.ts - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status