yasp-dota/yasp

View on GitHub

Showing 231 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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              '/players/{account_id}/wordcloud': {
                get: {
                  operationId: generateOperationId(
                    'get',
                    '/players/{account_id}/wordcloud',
          Severity: Major
          Found in routes/spec.ts and 1 other location - About 1 day to fix
          routes/spec.ts on lines 764..809

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 319.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              '/players/{account_id}/wardmap': {
                get: {
                  operationId: generateOperationId(
                    'get',
                    '/players/{account_id}/wardmap',
          Severity: Major
          Found in routes/spec.ts and 1 other location - About 1 day to fix
          routes/spec.ts on lines 810..855

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 319.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                '/players/{account_id}/peers': {
                  get: {
                    operationId: generateOperationId('get', '/players/{account_id}/peers'),
                    summary: 'GET /players/{account_id}/peers',
                    description: 'Players played with',
            Severity: Major
            Found in routes/spec.ts and 1 other location - About 1 day to fix
            routes/spec.ts on lines 542..579

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 243.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                '/players/{account_id}/pros': {
                  get: {
                    operationId: generateOperationId('get', '/players/{account_id}/pros'),
                    summary: 'GET /players/{account_id}/pros',
                    description: 'Pro players played with',
            Severity: Major
            Found in routes/spec.ts and 1 other location - About 1 day to fix
            routes/spec.ts on lines 504..541

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 243.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    '/heroes/{hero_id}/durations': {
                      get: {
                        operationId: generateOperationId('get', '/heroes/{hero_id}/durations'),
                        summary: 'GET /heroes/{hero_id}/durations',
                        description: 'Get hero performance over a range of match durations',
                Severity: Major
                Found in routes/spec.ts and 1 other location - About 7 hrs to fix
                routes/spec.ts on lines 1767..1818

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 181.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    '/scenarios/laneRoles': {
                      get: {
                        operationId: generateOperationId('get', '/scenarios/laneRoles'),
                        summary: 'GET /scenarios/laneRoles',
                        description: 'Win rates for heroes in certain lane roles',
                Severity: Major
                Found in routes/spec.ts and 1 other location - About 7 hrs to fix
                routes/spec.ts on lines 2391..2431

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 181.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    '/scenarios/itemTimings': {
                      get: {
                        operationId: generateOperationId('get', '/scenarios/itemTimings'),
                        summary: 'GET /scenarios/itemTimings',
                        description:
                Severity: Major
                Found in routes/spec.ts and 1 other location - About 7 hrs to fix
                routes/spec.ts on lines 2432..2471

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 181.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    '/heroes/{hero_id}/matches': {
                      get: {
                        operationId: generateOperationId('get', '/heroes/{hero_id}/matches'),
                        summary: 'GET /heroes/{hero_id}/matches',
                        description: 'Get recent matches with a hero',
                Severity: Major
                Found in routes/spec.ts and 1 other location - About 7 hrs to fix
                routes/spec.ts on lines 1862..1901

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 181.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                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

                    Similar blocks of code found in 5 locations. Consider refactoring.
                    Open

                        '/leagues/{league_id}/teams': {
                          get: {
                            operationId: generateOperationId('get', '/leagues/{league_id}/teams'),
                            summary: 'GET /leagues/{league_id}/teams',
                            description: 'Get teams for a league',
                    Severity: Major
                    Found in routes/spec.ts and 4 other locations - About 6 hrs to fix
                    routes/spec.ts on lines 2039..2069
                    routes/spec.ts on lines 2185..2222
                    routes/spec.ts on lines 2223..2259
                    routes/spec.ts on lines 2260..2296

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 163.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Severity
                    Category
                    Status
                    Source
                    Language