yasp-dota/yasp

View on GitHub

Showing 113 of 231 total issues

File spec.ts has 2591 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import constants from 'dotaconstants';
import moment from 'moment';
import pg from 'pg';
import config from '../config';
import { addJob, addReliableJob, getReliableJob } from '../store/queue';
Severity: Major
Found in routes/spec.ts - About 1 wk to fix

    Function insertMatch has 519 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function insertMatch(
      origMatch: Readonly<InsertMatchInput>,
      options: InsertMatchOptions,
    ) {
      async function upsertMatchPostgres(match: InsertMatchInput) {
    Severity: Major
    Found in store/insert.ts - About 2 days to fix

      File MatchResponse.ts has 958 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import commonProperties from './properties/commonProperties';
      
      export default {
        MatchResponse: {
          title: 'MatchResponse',
      Severity: Major
      Found in routes/responses/MatchResponse.ts - About 2 days to fix

        Function insertMatch has a Cognitive Complexity of 99 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function insertMatch(
          origMatch: Readonly<InsertMatchInput>,
          options: InsertMatchOptions,
        ) {
          async function upsertMatchPostgres(match: InsertMatchInput) {
        Severity: Minor
        Found in store/insert.ts - About 1 day 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

        File utility.ts has 777 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import constants from 'dotaconstants';
        import request from 'request';
        import urllib from 'url';
        import moment from 'moment';
        import crypto from 'crypto';
        Severity: Major
        Found in util/utility.ts - About 1 day to fix

          File insert.ts has 645 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import moment from 'moment';
          import constants from 'dotaconstants';
          import util from 'util';
          import fs from 'fs';
          import config from '../config';
          Severity: Major
          Found in store/insert.ts - About 1 day to fix

            obj has 65 functions (exceeds 20 allowed). Consider refactoring.
            Open

              const obj = {
                user_players: async () => redis.zcard('visitors'),
                user_players_recent: async () =>
                  redis.zcount(
                    'visitors',
            Severity: Major
            Found in store/buildStatus.ts - About 1 day to fix

              Function computeMatchData has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
              Open

              export function computeMatchData(pm: ParsedPlayerMatch) {
                const selfHero = constants.heroes[pm.hero_id];
                // Compute patch based on start_time
                if (pm.start_time) {
                  pm.patch = getPatchIndex(pm.start_time);
              Severity: Minor
              Found in util/compute.ts - About 1 day 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

              File web.ts has 528 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /**
               * Provides the OpenDota API and serves web requests
               * Also supports login through Steam
               * */
              import request from 'request';
              Severity: Major
              Found in svc/web.ts - About 1 day to fix

                Function computeMatchData has 178 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function computeMatchData(pm: ParsedPlayerMatch) {
                  const selfHero = constants.heroes[pm.hero_id];
                  // Compute patch based on start_time
                  if (pm.start_time) {
                    pm.patch = getPatchIndex(pm.start_time);
                Severity: Major
                Found in util/compute.ts - About 7 hrs to fix

                  Function upsertMatchPostgres has 170 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async function upsertMatchPostgres(match: InsertMatchInput) {
                      if (options.type !== 'api' && options.type !== 'parsed') {
                        // Only if API or parse data
                        return;
                      }
                  Severity: Major
                  Found in store/insert.ts - About 6 hrs to fix

                    Function buildStatus has 123 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export async function buildStatus() {
                      const obj = {
                        user_players: async () => redis.zcard('visitors'),
                        user_players_recent: async () =>
                          redis.zcount(
                    Severity: Major
                    Found in store/buildStatus.ts - About 4 hrs to fix

                      Function parseProcessor has 115 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      async function parseProcessor(job: ParseJob) {
                        const start = Date.now();
                        let apiTime = 0;
                        let gcTime = 0;
                        let parseTime = 0;
                      Severity: Major
                      Found in svc/parser.ts - About 4 hrs to fix

                        Function chat has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                        Open

                            function chat(match: ParsedMatch) {
                              // negative/positive words in chat before minute 1
                              const rows = [];
                              let radiantNegative = false;
                              let direNegative = false;
                        Severity: Minor
                        Found in util/scenariosUtil.ts - About 4 hrs 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 buildMatch has 108 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        async function buildMatch(
                          matchId: number,
                          options: { meta?: string },
                        ): Promise<Match | ParsedMatch | null> {
                          if (!matchId || !Number.isInteger(matchId) || matchId <= 0) {
                        Severity: Major
                        Found in store/buildMatch.ts - About 4 hrs to fix

                          Function runReliableQueue has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                          Open

                          export async function runReliableQueue(
                            queueName: QueueName,
                            parallelism: number,
                            processor: (job: any) => Promise<boolean>,
                            getCapacity?: () => Promise<number>,
                          Severity: Minor
                          Found in store/queue.ts - About 4 hrs 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 getSteamAPIDataCallback has 100 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function getSteamAPIDataCallback(url: string | GetDataOptions, cb: ErrorCb) {
                            let u: string;
                            let timeout = 5000;
                            if (typeof url === 'object' && url && url.url) {
                              u = url.url;
                          Severity: Major
                          Found in util/utility.ts - About 4 hrs to fix

                            Function processFullHistory has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            async function processFullHistory(job: FullHistoryJob) {
                              const player = job;
                              if (
                                Number(player.account_id) === 0 ||
                                Number.isNaN(Number(player.account_id))
                            Severity: Major
                            Found in svc/fullhistory.ts - About 3 hrs to fix

                              Consider simplifying this complex logical expression.
                              Open

                                    if (
                                      err ||
                                      !res ||
                                      res.statusCode !== 200 ||
                                      !body ||
                              Severity: Critical
                              Found in util/utility.ts - About 3 hrs to fix

                                Function parseProcessor has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                                Open

                                async function parseProcessor(job: ParseJob) {
                                  const start = Date.now();
                                  let apiTime = 0;
                                  let gcTime = 0;
                                  let parseTime = 0;
                                Severity: Minor
                                Found in svc/parser.ts - About 2 hrs 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