| Conditions | 7 |
| Total Lines | 71 |
| Code Lines | 59 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | import { IntlShape } from "react-intl"; |
||
| 72 | |||
| 73 | export function makeProgressBarSteps( |
||
| 74 | applicationId: number, |
||
| 75 | application: ApplicationNormalized | null, |
||
| 76 | intl: IntlShape, |
||
| 77 | currentStep: |
||
| 78 | | "welcome" |
||
| 79 | | "basic" |
||
| 80 | | "experience" |
||
| 81 | | "skills" |
||
| 82 | | "fit" |
||
| 83 | | "review" |
||
| 84 | | "submission" |
||
| 85 | | "other", |
||
| 86 | ): ProgressBarProps["steps"] { |
||
| 87 | const locale = getLocale(intl.locale); |
||
| 88 | return [ |
||
| 89 | { |
||
| 90 | link: { |
||
| 91 | url: applicationBasic(locale, applicationId), |
||
| 92 | text: intl.formatMessage(stepNames.step01), |
||
| 93 | title: intl.formatMessage(stepNames.step01), |
||
| 94 | }, |
||
| 95 | status: |
||
| 96 | currentStep === "basic" ? "current" : basicInfoStatus(application), |
||
| 97 | }, |
||
| 98 | { |
||
| 99 | link: { |
||
| 100 | url: applicationExperienceIntro(locale, applicationId), |
||
| 101 | text: intl.formatMessage(stepNames.step02), |
||
| 102 | title: intl.formatMessage(stepNames.step02), |
||
| 103 | }, |
||
| 104 | status: |
||
| 105 | currentStep === "experience" |
||
| 106 | ? "current" |
||
| 107 | : experienceStatus(application), |
||
| 108 | }, |
||
| 109 | { |
||
| 110 | link: { |
||
| 111 | url: applicationSkills(locale, applicationId), |
||
| 112 | text: intl.formatMessage(stepNames.step03), |
||
| 113 | title: intl.formatMessage(stepNames.step03), |
||
| 114 | }, |
||
| 115 | status: currentStep === "skills" ? "current" : skillsStatus(application), |
||
| 116 | }, |
||
| 117 | { |
||
| 118 | link: { |
||
| 119 | url: applicationFit(locale, applicationId), |
||
| 120 | text: intl.formatMessage(stepNames.step04), |
||
| 121 | title: intl.formatMessage(stepNames.step04), |
||
| 122 | }, |
||
| 123 | status: currentStep === "fit" ? "current" : myFitStatus(application), |
||
| 124 | }, |
||
| 125 | { |
||
| 126 | link: { |
||
| 127 | url: applicationReview(locale, applicationId), |
||
| 128 | text: intl.formatMessage(stepNames.step05), |
||
| 129 | title: intl.formatMessage(stepNames.step05), |
||
| 130 | }, |
||
| 131 | status: currentStep === "review" ? "current" : reviewStatus(application), |
||
| 132 | }, |
||
| 133 | { |
||
| 134 | link: { |
||
| 135 | url: applicationSubmission(locale, applicationId), |
||
| 136 | text: intl.formatMessage(stepNames.step06), |
||
| 137 | title: intl.formatMessage(stepNames.step06), |
||
| 138 | }, |
||
| 139 | status: |
||
| 140 | currentStep === "submission" |
||
| 141 | ? "current" |
||
| 142 | : submissionStatus(application), |
||
| 143 | }, |
||
| 148 |