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';
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) {
File MatchResponse.ts
has 958 lines of code (exceeds 250 allowed). Consider refactoring. Open
import commonProperties from './properties/commonProperties';
export default {
MatchResponse: {
title: 'MatchResponse',
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) {
- Read upRead up
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';
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';
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',
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);
- Read upRead up
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';
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);
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;
}
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(
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;
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;
- Read upRead up
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) {
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>,
- Read upRead up
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;
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))
Consider simplifying this complex logical expression. Open
if (
err ||
!res ||
res.statusCode !== 200 ||
!body ||
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;
- Read upRead up
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"