Showing 166 of 560 total issues

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

  static join(first: string, second: string): string {
    const firstEndsWithSlash = first.endsWith("/")
    const secondStartsWithSlash = second.startsWith("/")
    if (firstEndsWithSlash) {
      return secondStartsWithSlash ? first + second.substring(1) : first + second
Severity: Minor
Found in util/url/UrlUtil.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

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

  async fetch<T>(url: string, init: RequestInit = {}, resOut = {}): Promise<T> {
    init.headers = Object.assign({"User-Agent": this.randomUA()}, init.headers)
    console.debug("Fetching", url, "with", init)
    const response = await fetch(url, init)
    if (response.ok) {
Severity: Minor
Found in time/datasource/HttpSource.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

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

  function getSoftmaxtoOutputLinesData(outputNodeCount, activationLayerX, nodeRadius, outputLayerCoordinates,
                                       outputLayerX, classes) {
Severity: Minor
Found in people/a/AlammarJay/js/nn_calc.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

              for (let i = 0; i < dictWord.length; i++, matchStart++) {
                const dictWordChar = dictWord.charAt(i)
                const fileWordChar = contents.charAt(pos + matchStart)
                if (fileWordChar === badChar) {
                  score += 5
    Severity: Major
    Found in WordFinder.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                      if (choice.value !== false) {
                                          var knownPhenomenaProbabilities = choice.knownPhenomenaProbabilities;
                                          for (var p in knownPhenomenaProbabilities) {
                                              if (knownPhenomenaProbabilities.hasOwnProperty(p)) {
                                                  if (!zerosCount[p]) {
      Severity: Major
      Found in time/1/9/7/7/Poher_Matrice/matrix.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      if (choice.value !== false) {
                        var knownPhenomenaProbabilities = choice.knownPhenomenaProbabilities
                        for (var p in knownPhenomenaProbabilities) {
                          if (knownPhenomenaProbabilities.hasOwnProperty(p)) {
                            if (!zerosCount[p]) {
        Severity: Major
        Found in time/1/9/7/7/Poher_Matrice/matrix.es5.js - About 45 mins to fix

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

            protected async processDirs(context: HtmlRR0SsgContext, dirNames: string[]): Promise<void> {
              let peopleList = await this.service.getFromDirs(context, dirNames)
              if (this.filterOccupations.length > 0) {
                peopleList = peopleList.filter((p: People) => p.occupations.some(o => this.filterOccupations.includes(o)))
              }
          Severity: Minor
          Found in people/PeopleDirectoryStep.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

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

          function testCase(urlPath: string, dateTime: TimeContext, description: string, sources: Source[],
                            place?: NamedPlace): RR0CaseSummary {
          Severity: Minor
          Found in time/datasource/rr0/RR0TestCases.ts - About 35 mins to fix

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

              function getLayerXScale(numberOfLayers, layersRegionWidth, outputRegionWidth, marginLeft, nodeRadius) {
            Severity: Minor
            Found in people/a/AlammarJay/js/nn_calc.js - About 35 mins to fix

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

                  draw: function (layer, properties, activeRegionSVGGroup, layerInputs, tooltipDiv) {
              Severity: Minor
              Found in people/a/AlammarJay/js/nn_calc.js - About 35 mins to fix

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

                  protected replaceItem(context: HtmlRR0SsgContext, item: HTMLLIElement, i: number) {
                    const anchor = item.querySelector(".index-anchor")
                    if (!anchor) {
                      const idOrValue = item.getAttribute("id") || item.getAttribute("value")
                      let dateTime: string
                Severity: Minor
                Found in index/indexedReplacer.ts - 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

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

                  protected async drawImage(context: HtmlRR0SsgContext, canvasCtx: CanvasRenderingContext2D, dy = 0) {
                    const outDoc = context.outputFile.document
                    const docImages = outDoc.documentElement.getElementsByTagName("img")
                    let widthRatio = 0.5
                    let imageIndex = 0
                Severity: Minor
                Found in OpenGraphCommand.ts - 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

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

                  async update(parent?: Chapter) {
                    const file = this.context.outputFile;
                    const meta = file.meta;
                    const links = file.links;
                    if (parent) {
                Severity: Minor
                Found in book/Chapters.ts - 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

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

                  static fromFileName(context: HtmlRR0SsgContext, fileName = context.inputFile.name): TimeContext | undefined {
                    let timeContext: TimeContext | undefined
                    const timeExec = Time.parseFileName(fileName)
                    if (timeExec && timeExec.length > 5) {
                      const pageContext = context.clone()
                Severity: Minor
                Found in time/TimeContext.ts - 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

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

                var NN_trainer = function (svg_el, table_el, areas, prices, weight, bias, x1, y1, x2, y2,
                                           gradientDescentButton, gradientDescent10Button, gradientDescent100Button,
                                           gradientDescentConvergeButton, normalize, error_chart_el, heatmap_el,
                                           weightRange, biasRange, neuralNetworkGraphEl, analyticsCategory) {
                  this.svg_el = svg_el;
                Severity: Minor
                Found in people/a/AlammarJay/js/simple_nn.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

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

                  protected indexWords(context: HtmlRR0SsgContext, outputFile: HtmlSsgFile) {
                    const pageIndex = this.index.pages.length;
                    const nonSignificant = context.messages.nonSignificantWords;
                    const contents = this.getContents(outputFile.document);
                    const pageText = contents.toLowerCase();
                Severity: Minor
                Found in search/SearchCommand.ts - 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

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

                  async execute(context: C): Promise<HtmlSsgFile> {
                    const inputFile = context.inputFile
                    const outputFile = context.outputFile
                    const dom = outputFile.dom
                    const outputDoc = outputFile.document;
                Severity: Minor
                Found in LinkReplaceCommand.ts - 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

                  return value.toExponential(1);
                Severity: Major
                Found in people/a/AlammarJay/js/nnVizUtils.js - About 30 mins to fix

                  Function replaceElement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    static replaceElement(context: HtmlRR0SsgContext, timeFiles: string[], previousContext?: RR0SsgContext): HTMLElement {
                      let replacement: HTMLElement | undefined
                      const absoluteTimeStr = TimeUrlBuilder.fromContext(context)
                      let title = TimeTextBuilder.build(context)
                      let text = previousContext ? RelativeTimeTextBuilder.build(previousContext, context) : undefined
                  Severity: Minor
                  Found in time/TimeReplacer.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

                  Function createReplacer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    protected async createReplacer(context: HtmlRR0SsgContext): Promise<RegexReplacer> {
                      return {
                        replace: (_match: string, ..._args: any[]): string => {
                          const inputFile = context.inputFile
                          let title = inputFile.title
                  Severity: Minor
                  Found in time/SsiTitleReplaceCommand.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