Strilanc/Quirk

View on GitHub
src/base/Util.js

Summary

Maintainability
C
7 hrs
Test Coverage

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

class Util {
    /**
     * Checks a precondition, throwing an exception containing the given message in the case of failure.
     * @param {!boolean|*} expression
     * @param {=string} message
Severity: Minor
Found in src/base/Util.js - About 2 hrs to fix

    File Util.js has 269 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * Copyright 2017 Google Inc.
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
    Severity: Minor
    Found in src/base/Util.js - About 2 hrs to fix

      Function breakLine has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          static breakLine(text, maxWidth, measureWidth) {
              if (text === "") {
                  return [""];
              }
              let lines = [];
      Severity: Minor
      Found in src/base/Util.js - About 1 hr to fix

        Function reverseGroupMap has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            static reverseGroupMap(groupMap, includeGroupsForOriginalKeysEvenIfEmpty = false) {
                let result = new Map();
        
                if (includeGroupsForOriginalKeysEvenIfEmpty) {
                    for (let e of groupMap.keys()) {
        Severity: Minor
        Found in src/base/Util.js - About 55 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 breakLine has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            static breakLine(text, maxWidth, measureWidth) {
                if (text === "") {
                    return [""];
                }
                let lines = [];
        Severity: Minor
        Found in src/base/Util.js - 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

        There are no issues that match your filters.

        Category
        Status