src/blockBuilders/employeesCelebrationsBlockBuilder.ts
Function buildAnniversariesBlocks
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Open
const buildBirthdaysBlocks = (
employees: TBambooHREmployeeExtended[],
today: moment.Moment
): TSlackBlock[] => {
const birthdays = employees
File employeesCelebrationsBlockBuilder.ts
has 252 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import moment from 'moment';
import defaultMessage from '../constants/defaultMessage';
import { TBambooHREmployeeExtended, TSlackBlock, TSlackMessage } from '..';
import { FRIDAY_ISO_WEEKDAY } from '../common';
Function anniversaries
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
.reduce<TBambooHREmployeeExtended[]>((previousValue, employee) => {
const hireDateYear = moment(employee.hireDate).year();
const hireDateMonth = (moment(employee.hireDate).month() + 1)
.toString()
.padStart(2, '0');
Function buildFirstDayBlocks
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const buildFirstDayBlocks = (
employees: TBambooHREmployeeExtended[],
today: moment.Moment
): TSlackBlock[] => {
const firstDayEmployees = employees
Function birthdays
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
.reduce<TBambooHREmployeeExtended[]>((previousValue, employee) => {
const birthdayWithCurrentYear: string = `${today.year()}-${
employee.birthday
}`;
Function buildAnniversariesBlocks
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
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 buildBirthdaysBlocks
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
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
Avoid too many return
statements within this function. Open
Open
return previousValue;