bra1n/judgebot

View on GitHub

Showing 33 of 33 total issues

Function locateStores has a Cognitive Complexity of 11 (exceeds 5 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: 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 generateEmbed has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  generateEmbed(setList: WhatsInStandard): EmbedBuilder {
    const currentDate = new Date();
    const removedFutureAndPastSetList = setList.sets.filter((set) => {
      // A set is in standard if:
      // It has been released, and
Severity: Minor
Found in modules/standard.ts - About 1 hr to fix

Function find has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  find(lookup: string, subsection?: string) {
    const entry = this.ipgData[lookup];
    if (!entry) {
      let availableEntries = _.keys(this.ipgData);
      availableEntries.sort();
Severity: Minor
Found in modules/ipg.ts - About 1 hr to fix

Function updateServerCount has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function updateServerCount(bot: Client) {
  bot.user?.setPresence({
    activities: [
      {
        name:
Severity: Minor
Found in utils.ts - About 1 hr to fix

Function parseRules has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  parseRules(
    crText: string,
    glossaryEntries: Record<string, GlossaryEntry>
  ): Record<string, string> {
    const ruleNumberPrefixRe = /^(\d{3}\.\w*)\.?/;
Severity: Minor
Found in modules/cr.ts - About 1 hr to fix

Function generateStoreRequestBody has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  generateStoreRequestBody(geometry: any, count = 10) {
    let requestBody = {
      count,
      filter_mass_markets: true,
      language: "en-us",
Severity: Minor
Found in modules/store.ts - About 1 hr to fix

Function find has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  find(parameter: string): EmbedBuilder {
    if (parameter.indexOf("-") !== -1 || parameter.indexOf(".") !== -1) {
      // looks like a section query
      const section = this.mtrData.sections[parameter];
      if (section) {
Severity: Minor
Found in modules/mtr.ts - About 1 hr to fix

Function getBorderColor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  getBorderColor(card: Scry.Card | Scry.CardFace) {
    let color;
    if (!card.colors || card.colors.length === 0) {
      color = MtgCardLoader.colors.NONE;
      if (card.type_line && card.type_line.match(/artifact/i))
Severity: Minor
Found in modules/card.ts - About 55 mins 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 parseRules has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  parseRules(
    crText: string,
    glossaryEntries: Record<string, GlossaryEntry>
  ): Record<string, string> {
    const ruleNumberPrefixRe = /^(\d{3}\.\w*)\.?/;
Severity: Minor
Found in modules/cr.ts - About 55 mins 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 parseGlossary has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  parseGlossary(glossaryText: string) {
    const glossaryEntries: Record<string, GlossaryEntry> = {};

    for (const entry of glossaryText.split("\n\n")) {
      if (!entry.trim()) {
Severity: Minor
Found in modules/cr.ts - About 45 mins 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 find has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  find(lookup: string, subsection?: string) {
    const entry = this.ipgData[lookup];
    if (!entry) {
      let availableEntries = _.keys(this.ipgData);
      availableEntries.sort();
Severity: Minor
Found in modules/ipg.ts - About 35 mins 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 a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  generateEventsEmbed(
    { Address, Organization }: any,
    response: any,
    filters: any
  ): EmbedBuilder {
Severity: Minor
Found in modules/store.ts - About 35 mins 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

Avoid too many return statements within this function.
Open

      return {
        embeds: [
          await this.generateErrorEmbed(
            null,
            `Location \`${location}\` not found.`
Severity: Major
Found in modules/store.ts - About 30 mins to fix
Severity
Category
Status
Source
Language