onebeyond/bamboohrbot

View on GitHub
src/blockBuilders/employeesCelebrationsBlockBuilder.ts

Summary

Maintainability
D
1 day
Test Coverage

Function buildAnniversariesBlocks has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const buildAnniversariesBlocks = (
  employees: TBambooHREmployeeExtended[],
  today: moment.Moment
): TSlackBlock[] => {
  const anniversaries = employees
Severity: Major
Found in src/blockBuilders/employeesCelebrationsBlockBuilder.ts - About 3 hrs to fix

    Function buildBirthdaysBlocks has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const buildBirthdaysBlocks = (
      employees: TBambooHREmployeeExtended[],
      today: moment.Moment
    ): TSlackBlock[] => {
      const birthdays = employees
    Severity: Major
    Found in src/blockBuilders/employeesCelebrationsBlockBuilder.ts - About 2 hrs to fix

      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';
      Severity: Minor
      Found in src/blockBuilders/employeesCelebrationsBlockBuilder.ts - About 2 hrs to fix

        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');
        Severity: Minor
        Found in src/blockBuilders/employeesCelebrationsBlockBuilder.ts - About 1 hr to fix

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

          const buildFirstDayBlocks = (
            employees: TBambooHREmployeeExtended[],
            today: moment.Moment
          ): TSlackBlock[] => {
            const firstDayEmployees = employees
          Severity: Minor
          Found in src/blockBuilders/employeesCelebrationsBlockBuilder.ts - About 1 hr to fix

            Function birthdays has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                .reduce<TBambooHREmployeeExtended[]>((previousValue, employee) => {
                  const birthdayWithCurrentYear: string = `${today.year()}-${
                    employee.birthday
                  }`;
            
            
            Severity: Minor
            Found in src/blockBuilders/employeesCelebrationsBlockBuilder.ts - About 1 hr to fix

              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
              Severity: Minor
              Found in src/blockBuilders/employeesCelebrationsBlockBuilder.ts - About 55 mins 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 buildBirthdaysBlocks has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              const buildBirthdaysBlocks = (
                employees: TBambooHREmployeeExtended[],
                today: moment.Moment
              ): TSlackBlock[] => {
                const birthdays = employees
              Severity: Minor
              Found in src/blockBuilders/employeesCelebrationsBlockBuilder.ts - About 55 mins 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

              Avoid too many return statements within this function.
              Open

                    return previousValue;
              Severity: Major
              Found in src/blockBuilders/employeesCelebrationsBlockBuilder.ts - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status