Lichess4545/Chesster

View on GitHub

Showing 173 of 173 total issues

File slack.ts has 945 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// -----------------------------------------------------------------------------
// Bot / Slack related helpers
// -----------------------------------------------------------------------------
import { RTMClient } from '@slack/rtm-api'
import {
Severity: Major
Found in src/slack.ts - About 2 days to fix

    File league.ts has 572 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // -----------------------------------------------------------------------------
    // Defines a league object which can be used to interact with the website
    // for the given league
    // -----------------------------------------------------------------------------
    import _ from 'lodash'
    Severity: Major
    Found in src/league.ts - About 1 day to fix

      File games.ts has 560 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      // -----------------------------------------------------------------------------
      // Commands and helpers related to gamelinks and results
      // -----------------------------------------------------------------------------
      import _ from 'lodash'
      import moment from 'moment-timezone'
      Severity: Major
      Found in src/commands/games.ts - About 1 day to fix

        File scheduling.ts has 558 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        // -----------------------------------------------------------------------------
        // Commands and helpers for scheduling games
        // -----------------------------------------------------------------------------
        import moment from 'moment-timezone'
        import _ from 'lodash'
        Severity: Major
        Found in src/commands/scheduling.ts - About 1 day to fix

          File heltour.ts has 493 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          // -----------------------------------------------------------------------------
          // Heltour related facilities
          // -----------------------------------------------------------------------------
          import _ from 'lodash'
          import winston from 'winston'
          Severity: Minor
          Found in src/heltour.ts - About 7 hrs to fix

            File lichess.ts has 491 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            // -----------------------------------------------------------------------------
            // Lichess API helpers
            // -----------------------------------------------------------------------------
            import * as http from './http'
            import moment from 'moment-timezone'
            Severity: Minor
            Found in src/lichess.ts - About 7 hrs to fix

              File subscription.ts has 480 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              // -----------------------------------------------------------------------------
              // Commands and helpers related to subscriptions
              // -----------------------------------------------------------------------------
              import _ from 'lodash'
              import winston from 'winston'
              Severity: Minor
              Found in src/commands/subscription.ts - About 7 hrs to fix

                File availability.ts has 454 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                // -----------------------------------------------------------------------------
                // Commands related to availability
                // -----------------------------------------------------------------------------
                import winston from 'winston'
                import _ from 'lodash'
                Severity: Minor
                Found in src/commands/availability.ts - About 6 hrs to fix

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

                  export async function subscribeTeams(bot: SlackBot, message: CommandMessage) {
                      const convo = await bot.startPrivateConversation([message.user])
                      return processTeamSubscribeCommand(bot, message)
                          .then((response) => {
                              bot.say({
                  Severity: Major
                  Found in src/commands/subscription.ts and 1 other location - About 6 hrs to fix
                  src/commands/subscription.ts on lines 553..570

                  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 161.

                  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

                  export async function listHandler(bot: SlackBot, message: CommandMessage) {
                      const convo = await bot.startPrivateConversation([message.user])
                      return processSubscriptionListCommand(bot, message)
                          .then((response) => {
                              bot.say({
                  Severity: Major
                  Found in src/commands/subscription.ts and 1 other location - About 6 hrs to fix
                  src/commands/subscription.ts on lines 597..614

                  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 161.

                  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 ambientScheduling has 147 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export async function ambientScheduling(
                      bot: SlackBot,
                      message: LeagueCommandMessage
                  ) {
                      const league = message.league
                  Severity: Major
                  Found in src/commands/scheduling.ts - About 5 hrs to fix

                    Function processGameDetails has 147 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        async processGameDetails(details: lichess.GameDetails) {
                            fp.each(async (league) => {
                                // 1. perfect match any time, try to update.
                                // 2. pairing + time control match any time, warn for other mismatches
                                // 3. pairing match during a 4 hour window (+-2 hours), warn for other mismatches
                    Severity: Major
                    Found in src/watcher.ts - About 5 hrs to fix

                      Function assignAlternate has 132 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function assignAlternate(bot: SlackBot, message: LeagueCommandMessage) {
                          const alternateOptions = message.league.config.alternate
                          if (
                              !alternateOptions ||
                              !_.isEqual(message.channel.id, alternateOptions.channelId)
                      Severity: Major
                      Found in src/commands/availability.ts - About 5 hrs to fix

                        File watcher.ts has 384 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        // -----------------------------------------------------------------------------
                        // Watcher uses the game-stream API from Lichess to listen for games as they
                        // start and end.
                        // -----------------------------------------------------------------------------
                        
                        
                        Severity: Minor
                        Found in src/watcher.ts - About 5 hrs to fix

                          Function updateAvailability has 115 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function updateAvailability(
                              bot: SlackBot,
                              message: LeagueCommandMessage
                          ) {
                              const heltourOptions = message.league.config.heltour
                          Severity: Major
                          Found in src/commands/availability.ts - About 4 hrs to fix

                            File config.ts has 358 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            // -----------------------------------------------------------------------------
                            // Types and parsing for the chesster config.
                            // -----------------------------------------------------------------------------
                            import moment from 'moment'
                            import {
                            Severity: Minor
                            Found in src/config.ts - About 4 hrs to fix

                              Function ambientScheduling has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                              Open

                              export async function ambientScheduling(
                                  bot: SlackBot,
                                  message: LeagueCommandMessage
                              ) {
                                  const league = message.league
                              Severity: Minor
                              Found in src/commands/scheduling.ts - About 4 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

                              League has 33 functions (exceeds 20 allowed). Consider refactoring.
                              Open

                              export class League {
                                  private log: LogWithPrefix
                              
                                  constructor(
                                      public bot: SlackBot,
                              Severity: Minor
                              Found in src/league.ts - About 4 hrs to fix

                                Function watch has 104 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    watch() {
                                        if (this.stop()) {
                                            return // The .on('end') handler will restart us.
                                        }
                                
                                
                                Severity: Major
                                Found in src/watcher.ts - About 4 hrs to fix

                                  Function processTellCommand has 98 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  function processTellCommand(
                                      bot: SlackBot,
                                      message: CommandMessage
                                  ): Promise<string> {
                                      return new Promise((resolve, reject) => {
                                  Severity: Major
                                  Found in src/commands/subscription.ts - About 3 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language