bra1n/judgebot

View on GitHub

Showing 33 of 33 total issues

File store.ts has 561 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Fuse from "fuse.js";

const log = utils.getLogger("locator");
import fetch from "node-fetch";
import * as utils from "../utils.js";
Severity: Major
Found in modules/store.ts - About 1 day to fix

File card.ts has 432 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  ButtonInteraction,
  CommandInteraction,
  Message,
  MessageActionRowComponentResolvable,
Severity: Minor
Found in modules/card.ts - About 6 hrs to fix

Function generateResponse has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

  async generateResponse(
    cards: JudgebotCard[],
    command: string,
    hasEmojiPermission: boolean
  ) {
Severity: Minor
Found in modules/card.ts - About 5 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 generateResponse has 114 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async generateResponse(
    cards: JudgebotCard[],
    command: string,
    hasEmojiPermission: boolean
  ) {
Severity: Major
Found in modules/card.ts - About 4 hrs to fix

File hangman.ts has 342 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import _ from "lodash";
import * as utils from "../utils.js";
import MtgCardLoader from "./card.js";
import {
  ActionRowBuilder,
Severity: Minor
Found in modules/hangman.ts - About 4 hrs to fix

Function locateStores has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async locateStores(location: any): Promise<InteractionReplyOptions> {
    const count = 10; // number of "stores" to retrieve (error margin included for non-store results)
    let googleBody: any;
    try {
      const res = await fetch(
Severity: Major
Found in modules/store.ts - About 3 hrs to fix

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

  generateMessage() {
    const missing = this.missing;
    const wrong = this.wrong;
    let totalGuesses = this.letters.size + this.wrongGuesses;

Severity: Minor
Found in modules/hangman.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

Function generateEventsEmbed has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  generateEventsEmbed(
    { Address, Organization }: any,
    response: any,
    filters: any
  ): EmbedBuilder {
Severity: Major
Found in modules/store.ts - About 2 hrs to fix

File ipg.ts has 277 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  ApplicationCommandOptionChoiceData,
  ApplicationCommandOptionType,
  AutocompleteInteraction,
  CommandInteraction,
Severity: Minor
Found in modules/ipg.ts - About 2 hrs to fix

Function fetchStores has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async fetchStores(longitude = -180, distance = 10) {
    try {
      if (longitude > 180 - distance) {
        // fetchStores(longitude = 0, distance = 10) { // easier testing
        //     if (longitude > 20 - distance) {
Severity: Major
Found in modules/store.ts - About 2 hrs to fix

Function generateMessage has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  generateMessage() {
    const missing = this.missing;
    const wrong = this.wrong;
    let totalGuesses = this.letters.size + this.wrongGuesses;

Severity: Major
Found in modules/hangman.ts - About 2 hrs to fix

Function getEvents has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async getEvents(query: string): Promise<EmbedBuilder> {
    // check if there are filters present
    const filters: any = {};
    let parameters = query.toLowerCase().split(" ");
    if (parameters.length == 0) {
Severity: Major
Found in modules/store.ts - About 2 hrs to fix

Function hangman has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  @Slash({
    name: "hangman",
    description:
      "Start a game of hangman, where you have to guess the card name with reaction letters",
  })
Severity: Major
Found in modules/hangman.ts - About 2 hrs to fix

Function generateStoreEmbed has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async generateStoreEmbed(
    stores: any,
    googleResult: any
  ): Promise<InteractionReplyOptions> {
    const fields: any = [];
Severity: Minor
Found in modules/store.ts - About 1 hr to fix

Function cr has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  @Slash({
    name: "cr",
    description: "Show a rule or definition from the Comprehensive Rulebook",
  })
  async cr(
Severity: Minor
Found in modules/cr.ts - About 1 hr 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 handleInteraction has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async handleInteraction(
    command: string,
    parameter: string,
    interaction: CommandInteraction
  ) {
Severity: Minor
Found in modules/card.ts - About 1 hr to fix

Function handleInteraction has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  async handleInteraction(
    command: string,
    parameter: string,
    interaction: CommandInteraction
  ) {
Severity: Minor
Found in modules/card.ts - About 1 hr 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 cr has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  @Slash({
    name: "cr",
    description: "Show a rule or definition from the Comprehensive Rulebook",
  })
  async cr(
Severity: Minor
Found in modules/cr.ts - About 1 hr to fix

Function getEvents has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  async getEvents(query: string): Promise<EmbedBuilder> {
    // check if there are filters present
    const filters: any = {};
    let parameters = query.toLowerCase().split(" ");
    if (parameters.length == 0) {
Severity: Minor
Found in modules/store.ts - About 1 hr 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 generateDescriptionText has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  generateDescriptionText(card: Scry.Card) {
    const ptToString = (card: Scry.CardFace | Scry.Card) =>
      `**${card.power?.replace(/\*/g, "\\*")}/${card.toughness?.replace(
        /\*/g,
        "\\*"
Severity: Minor
Found in modules/card.ts - About 1 hr to fix
Severity
Category
Status
Source
Language