Showing 15 of 15 total issues
Function buildAnniversariesBlocks
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
const buildAnniversariesBlocks = (
employees: TBambooHREmployeeExtended[],
today: moment.Moment
): TSlackBlock[] => {
const anniversaries = employees
Function buildBirthdaysBlocks
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
const buildBirthdaysBlocks = (
employees: TBambooHREmployeeExtended[],
today: moment.Moment
): TSlackBlock[] => {
const birthdays = employees
Function bankHolidaysBlockBuilder
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function bankHolidaysBlockBuilder(
bankHolidays: TWhosOut,
today: moment.Moment
): TSlackMessage {
const monthBankHolidaysBlocks: any[] = [];
Function employeesAtOfficeBlockBuilder
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function employeesAtOfficeBlockBuilder(
employees: TBambooHREmployeeExtended[],
employeesAtOffice: TBambooHREmployeeAtOffice[],
today: moment.Moment
): TSlackMessage {
File employeesCelebrationsBlockBuilder.ts
has 252 lines of code (exceeds 250 allowed). Consider refactoring. Open
import moment from 'moment';
import defaultMessage from '../constants/defaultMessage';
import { TBambooHREmployeeExtended, TSlackBlock, TSlackMessage } from '..';
import { FRIDAY_ISO_WEEKDAY } from '../common';
Function main
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function main() {
initializeSecretsManager();
const slackBotToken = await getSecret('SLACK_BOT_TOKEN');
const slackSigningSecret = await getSecret('SLACK_SIGNING_SECRET');
Function buildFirstDayBlocks
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
const buildFirstDayBlocks = (
employees: TBambooHREmployeeExtended[],
today: moment.Moment
): TSlackBlock[] => {
const firstDayEmployees = employees
Function anniversaries
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
.reduce<TBambooHREmployeeExtended[]>((previousValue, employee) => {
const hireDateYear = moment(employee.hireDate).year();
const hireDateMonth = (moment(employee.hireDate).month() + 1)
.toString()
.padStart(2, '0');
Function birthdays
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
.reduce<TBambooHREmployeeExtended[]>((previousValue, employee) => {
const birthdayWithCurrentYear: string = `${today.year()}-${
employee.birthday
}`;
Consider simplifying this complex logical expression. Open
if (
bankHolidays.month.length > 0 &&
((today.date() === 1 && today.isoWeekday() <= FRIDAY_ISO_WEEKDAY) ||
(today.date() === 2 && today.isoWeekday() === MONDAY_ISO_WEEKDAY) ||
(today.date() === 3 && today.isoWeekday() === MONDAY_ISO_WEEKDAY))
Function bankHolidaysBlockBuilder
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export default function bankHolidaysBlockBuilder(
bankHolidays: TWhosOut,
today: moment.Moment
): TSlackMessage {
const monthBankHolidaysBlocks: any[] = [];
- 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
Function buildBirthdaysBlocks
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const buildBirthdaysBlocks = (
employees: TBambooHREmployeeExtended[],
today: moment.Moment
): TSlackBlock[] => {
const birthdays = employees
- 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
Function buildAnniversariesBlocks
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const buildAnniversariesBlocks = (
employees: TBambooHREmployeeExtended[],
today: moment.Moment
): TSlackBlock[] => {
const anniversaries = employees
- 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
Function employeesAtOfficeBlockBuilder
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export default function employeesAtOfficeBlockBuilder(
employees: TBambooHREmployeeExtended[],
employeesAtOffice: TBambooHREmployeeAtOffice[],
today: moment.Moment
): TSlackMessage {
- 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
Avoid too many return
statements within this function. Open
return previousValue;