onebeyond/bamboohrbot

View on GitHub

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

      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[] = [];
      Severity: Major
      Found in src/blockBuilders/bankHolidaysBlockBuilder.ts - About 2 hrs to fix

        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 {
        Severity: Major
        Found in src/blockBuilders/employeesAtOfficeBlockBuilder.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 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');
            Severity: Minor
            Found in src/handler.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 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 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

                    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))
                    Severity: Major
                    Found in src/blockBuilders/bankHolidaysBlockBuilder.ts - About 1 hr to fix

                      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[] = [];
                      Severity: Minor
                      Found in src/blockBuilders/bankHolidaysBlockBuilder.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

                      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 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 {
                      Severity: Minor
                      Found in src/blockBuilders/employeesAtOfficeBlockBuilder.ts - About 45 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
                        Severity
                        Category
                        Status
                        Source
                        Language