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 {
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'
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'
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'
File heltour.ts
has 493 lines of code (exceeds 250 allowed). Consider refactoring. Open
// -----------------------------------------------------------------------------
// Heltour related facilities
// -----------------------------------------------------------------------------
import _ from 'lodash'
import winston from 'winston'
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'
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'
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'
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({
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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({
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
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
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)
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.
// -----------------------------------------------------------------------------
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
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 {
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
- 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
League
has 33 functions (exceeds 20 allowed). Consider refactoring. Open
export class League {
private log: LogWithPrefix
constructor(
public bot: SlackBot,
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.
}
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) => {