Lichess4545/Chesster

View on GitHub

Showing 173 of 173 total issues

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

    formatRulesLinkResponse() {
        if (this.config.links.rules) {
            return `Here are the rules and regulations:\n${this.config.links.rules}`
        } else {
            return `The ${this.name} league does not have a rules link.`
Severity: Major
Found in src/league.ts and 2 other locations - About 2 hrs to fix
src/league.ts on lines 478..484
src/league.ts on lines 489..495

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

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 3 locations. Consider refactoring.
Open

    formatStarterGuideResponse() {
        if (this.config.links.guide) {
            return `Here is everything you need to know:\n${this.config.links.guide}`
        } else {
            return `The ${this.name} league does not have a starter guide.`
Severity: Major
Found in src/league.ts and 2 other locations - About 2 hrs to fix
src/league.ts on lines 467..473
src/league.ts on lines 489..495

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

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

function getPossibleDateStrings(dateString: string, extrema: Extrema) {
    const dateStrings = []

    // Unify some common stuff first.
    //
Severity: Major
Found in src/commands/scheduling.ts - About 2 hrs to fix

    Function parseScheduling has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function parseScheduling(
        inputString: string,
        options: config.Scheduling
    ): SchedulingResult {
        const parts = getTokensScheduling(inputString)
    Severity: Major
    Found in src/commands/scheduling.ts - About 2 hrs to fix

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

          async start() {
              // Connect to Slack
              const { self, team } = await this.rtm.start()
              this.controller = self as SlackBotSelf
              this.team = team as SlackTeam
      Severity: Major
      Found in src/slack.ts - About 2 hrs to fix

        Function ambientResults has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function ambientResults(
            bot: SlackBot,
            message: LeagueCommandMessage
        ) {
            const league: League = message.league
        Severity: Minor
        Found in src/commands/games.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 refreshRosters has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            async refreshRosters() {
                const newPlayers: Player[] = []
                const newPlayerLookup: Record<string, Player> = {}
                const newTeams: Team[] = []
                const newTeamLookup: Record<string, Team> = {}
        Severity: Minor
        Found in src/league.ts - About 1 hr to fix

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

          export async function setAvailability(
              heltourConfig: LeagueConfig,
              playerName: string,
              available: boolean,
              roundNumber: number
          Severity: Major
          Found in src/heltour.ts and 1 other location - About 1 hr to fix
          src/heltour.ts on lines 540..555

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

          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 sendGameWarning(
              heltourConfig: LeagueConfig,
              white: string,
              black: string,
              reason: string
          Severity: Major
          Found in src/heltour.ts and 1 other location - About 1 hr to fix
          src/heltour.ts on lines 523..538

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

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

          export function fetchURLIntoJSON(
              options: RequestOptions | string
          ): Promise<JSONResponse> {
              return new Promise((resolve, reject) => {
                  fetchURL(options).then(
          Severity: Minor
          Found in src/http.ts - About 1 hr to fix

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

            function getLeague(
                bot: SlackBot,
                message: ChessterMessage,
                channelOnly: boolean
            ): league.League | undefined {
            Severity: Minor
            Found in src/slack.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 schedulingReplyScheduled has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function schedulingReplyScheduled(
                bot: SlackBot,
                message: LeagueCommandMessage,
                results: SchedulingResult,
                white: LeagueMember,
            Severity: Minor
            Found in src/commands/scheduling.ts - About 1 hr to fix

              Function fetchURL has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function fetchURL(
                  optionsOrString: RequestOptions | string
              ): Promise<Response> {
                  let options: RequestOptions
                  if (isString(optionsOrString)) {
              Severity: Minor
              Found in src/http.ts - About 1 hr to fix

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

                export const PoolDecoder: Decoder<Pool> = object(
                    ['max', number()],
                    ['min', number()],
                    ['idle', number()],
                    (max, min, idle) => ({ max, min, idle })
                Severity: Major
                Found in src/config.ts and 2 other locations - About 1 hr to fix
                src/heltour.ts on lines 214..223
                src/lichess.ts on lines 303..308

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

                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 3 locations. Consider refactoring.
                Open

                export const TeamPlayerDecoder: Decoder<TeamPlayer> = object(
                    ['username', string()],
                    ['is_captain', boolean()],
                    ['board_number', number()],
                    (username, isCaptain, boardNumber) => ({
                Severity: Major
                Found in src/heltour.ts and 2 other locations - About 1 hr to fix
                src/config.ts on lines 283..288
                src/lichess.ts on lines 303..308

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

                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 3 locations. Consider refactoring.
                Open

                export const OpeningDecoder: Decoder<Opening> = object(
                    ['eco', string()],
                    ['name', string()],
                    ['ply', number()],
                    (eco, name, ply) => ({ eco, name, ply })
                Severity: Major
                Found in src/lichess.ts and 2 other locations - About 1 hr to fix
                src/config.ts on lines 283..288
                src/heltour.ts on lines 214..223

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

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

                function processTeamSubscribeCommand(
                    bot: SlackBot,
                    message: CommandMessage
                ): Promise<string> {
                    return new Promise((resolve, reject) => {
                Severity: Minor
                Found in src/commands/subscription.ts - About 1 hr to fix

                  Function updatesUsers has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      async updatesUsers() {
                          // Get our lichess username to slack username map
                          const slackIDByLichessUsername = await heltour.getUserMap(
                              this.config.heltour
                          )
                  Severity: Minor
                  Found in src/slack.ts - About 1 hr to fix

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

                                        if (!this.fullyQuit) {
                                            this.log.info(`Restarting watcher`)
                                            this.watch()
                                        } else {
                                            this.log.info(
                    Severity: Major
                    Found in src/watcher.ts and 1 other location - About 1 hr to fix
                    src/watcher.ts on lines 139..146

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

                    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

                        if (
                            white.tz &&
                            moment().tz(white.tz).utcOffset() !== whiteDate.utcOffset()
                        ) {
                            dateFormats +=
                    Severity: Major
                    Found in src/commands/scheduling.ts and 1 other location - About 1 hr to fix
                    src/commands/scheduling.ts on lines 457..465

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

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language