| Conditions | 7 |
| Total Lines | 64 |
| Code Lines | 52 |
| 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"; |
||
| 14 | |||
| 15 | export function makeProgressBarSteps( |
||
| 16 | applicationId: number, |
||
| 17 | steps: { [key in string]: ProgressBarStatus }, |
||
| 18 | intl: IntlShape, |
||
| 19 | currentStep: |
||
| 20 | | "welcome" |
||
| 21 | | "basic" |
||
| 22 | | "experience" |
||
| 23 | | "skills" |
||
| 24 | | "fit" |
||
| 25 | | "review" |
||
| 26 | | "submission" |
||
| 27 | | "other", |
||
| 28 | ): ProgressBarProps["steps"] { |
||
| 29 | const locale = getLocale(intl.locale); |
||
| 30 | return [ |
||
| 31 | { |
||
| 32 | link: { |
||
| 33 | url: applicationBasic(locale, applicationId), |
||
| 34 | text: intl.formatMessage(stepNames.step01), |
||
| 35 | title: intl.formatMessage(stepNames.step01), |
||
| 36 | }, |
||
| 37 | status: currentStep === "basic" ? "current" : steps.basic, |
||
| 38 | }, |
||
| 39 | { |
||
| 40 | link: { |
||
| 41 | url: applicationExperienceIntro(locale, applicationId), |
||
| 42 | text: intl.formatMessage(stepNames.step02), |
||
| 43 | title: intl.formatMessage(stepNames.step02), |
||
| 44 | }, |
||
| 45 | status: currentStep === "experience" ? "current" : steps.experience, |
||
| 46 | }, |
||
| 47 | { |
||
| 48 | link: { |
||
| 49 | url: applicationSkills(locale, applicationId), |
||
| 50 | text: intl.formatMessage(stepNames.step03), |
||
| 51 | title: intl.formatMessage(stepNames.step03), |
||
| 52 | }, |
||
| 53 | status: currentStep === "skills" ? "current" : steps.skills, |
||
| 54 | }, |
||
| 55 | { |
||
| 56 | link: { |
||
| 57 | url: applicationFit(locale, applicationId), |
||
| 58 | text: intl.formatMessage(stepNames.step04), |
||
| 59 | title: intl.formatMessage(stepNames.step04), |
||
| 60 | }, |
||
| 61 | status: currentStep === "fit" ? "current" : steps.fit, |
||
| 62 | }, |
||
| 63 | { |
||
| 64 | link: { |
||
| 65 | url: applicationReview(locale, applicationId), |
||
| 66 | text: intl.formatMessage(stepNames.step05), |
||
| 67 | title: intl.formatMessage(stepNames.step05), |
||
| 68 | }, |
||
| 69 | status: currentStep === "review" ? "current" : steps.review, |
||
| 70 | }, |
||
| 71 | { |
||
| 72 | link: { |
||
| 73 | url: applicationSubmission(locale, applicationId), |
||
| 74 | text: intl.formatMessage(stepNames.step06), |
||
| 75 | title: intl.formatMessage(stepNames.step06), |
||
| 76 | }, |
||
| 77 | status: currentStep === "submission" ? "current" : steps.submission, |
||
| 78 | }, |
||
| 83 |