Showing 35 of 169 total issues
Function parseIRCMessage
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
export function parseIRCMessage(messageSrc: string): IRCMessage {
let remainder = messageSrc;
let ircTags: IRCMessageTags;
if (messageSrc.startsWith("@")) {
- 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 join-all.spec.ts
has 408 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { assert } from "chai";
import * as sinon from "sinon";
import { TimeoutError } from "../await/timeout-error";
import { assertErrorChain, fakeConnection } from "../helpers.spec";
import { JoinError } from "./join";
Function parseIRCMessage
has 125 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function parseIRCMessage(messageSrc: string): IRCMessage {
let remainder = messageSrc;
let ircTags: IRCMessageTags;
if (messageSrc.startsWith("@")) {
File alternate-message-modifier.spec.ts
has 329 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { assert } from "chai";
import "mocha";
import { promisify } from "util";
import { fakeClient } from "../helpers.spec";
import {
ChatClient
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
export class ChatClient extends BaseClient {
public get wantedChannels(): Set<string> {
return unionSets(this.connections.map((c) => c.wantedChannels));
}
File irc-message.spec.ts
has 267 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { assert } from "chai";
import { assertThrowsChain } from "../../helpers.spec";
import { IRCMessage } from "../irc/irc-message";
import { parseIRCMessage } from "./irc-message";
import { ParseError } from "./parse-error";
File client.ts
has 267 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as debugLogger from "debug-logger";
import { getMods, getVips } from "../operations/get-mods-vips";
import { ClientConfiguration } from "../config/config";
import { Color } from "../message/color";
import { ClientMixin, ConnectionMixin } from "../mixins/base-mixin";
File tag-values.spec.ts
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { assert } from "chai";
import { assertThrowsChain } from "../../helpers.spec";
import { TwitchBadge } from "../badge";
import { TwitchBadgesList } from "../badges";
import { TwitchEmote } from "../emote";
Function expandTransportConfig
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
export function expandTransportConfig(
config: TransportConfiguration | undefined
): ExpandedTransportConfiguration {
if (config == null) {
return expandTransportConfig({
- 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 acquire
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async acquire(
channelName: string
): Promise<(() => void) | undefined> {
const { fastSpam, certain } = canSpamFast(
channelName,
Function expandTransportConfig
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function expandTransportConfig(
config: TransportConfiguration | undefined
): ExpandedTransportConfiguration {
if (config == null) {
return expandTransportConfig({
Function parseEmotes
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export function parseEmotes(
messageText: string,
emotesSrc: string
): TwitchEmoteList {
const emotes: TwitchEmoteList = [];
- 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 newConnection
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public newConnection(): SingleConnection {
const conn = new SingleConnection(this.configuration);
log.debug(`Creating new connection (ID ${conn.connectionID})`);
Function applyToClient
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public applyToClient(client: ChatClient): void {
type GenericReplacementFn = (
oldFn: (channelName: string, message: string) => Promise<void>,
channelName: string,
message: string
Function parseFlags
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export function parseFlags(
messageText: string,
flagsSrc: string
): TwitchFlagList {
const flags: TwitchFlagList = [];
- 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 constructor
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public constructor(configuration?: ClientConfiguration) {
super(configuration);
this.on("error", (e) => {
if (anyCauseInstanceof(e, ConnectionError)) {
Function createMockTransport
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function createMockTransport(): MockTransportData {
const data: any[] = [];
const transport = new Duplex({
autoDestroy: true,
Function fakeClient
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function fakeClient(connect = true): FakeClientData {
const transports: MockTransportData[] = [];
const getStream = (): Duplex => {
const newTransport = createMockTransport();
Function applyToClient
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public applyToClient(client: ChatClient): void {
const genericReplament = async (
oldFn: (channelName: string, message: string) => Promise<void>,
channelName: string,
message: string
Function splitIntoChunks
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function splitIntoChunks(
bits: string[],
separator = " ",
limit: number
): string[][] {