Conditions | 7 |
Total Lines | 70 |
Code Lines | 58 |
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"; |
||
42 | |||
43 | export function makeProgressBarSteps( |
||
44 | application: Application, |
||
45 | intl: IntlShape, |
||
46 | currentStep: |
||
47 | | "welcome" |
||
48 | | "basic" |
||
49 | | "experience" |
||
50 | | "skills" |
||
51 | | "fit" |
||
52 | | "review" |
||
53 | | "submission" |
||
54 | | "other", |
||
55 | ): ProgressBarProps["steps"] { |
||
56 | const locale = getLocale(intl.locale); |
||
57 | return [ |
||
58 | { |
||
59 | link: { |
||
60 | url: applicationBasic(locale, application.id), |
||
61 | text: intl.formatMessage(stepNames.step01), |
||
62 | title: intl.formatMessage(stepNames.step01), |
||
63 | }, |
||
64 | status: |
||
65 | currentStep === "basic" ? "current" : basicInfoStatus(application), |
||
66 | }, |
||
67 | { |
||
68 | link: { |
||
69 | url: applicationExperienceIntro(locale, application.id), |
||
70 | text: intl.formatMessage(stepNames.step02), |
||
71 | title: intl.formatMessage(stepNames.step02), |
||
72 | }, |
||
73 | status: |
||
74 | currentStep === "experience" |
||
75 | ? "current" |
||
76 | : experienceStatus(application), |
||
77 | }, |
||
78 | { |
||
79 | link: { |
||
80 | url: applicationSkills(locale, application.id), |
||
81 | text: intl.formatMessage(stepNames.step03), |
||
82 | title: intl.formatMessage(stepNames.step03), |
||
83 | }, |
||
84 | status: currentStep === "skills" ? "current" : skillsStatus(application), |
||
85 | }, |
||
86 | { |
||
87 | link: { |
||
88 | url: applicationFit(locale, application.id), |
||
89 | text: intl.formatMessage(stepNames.step04), |
||
90 | title: intl.formatMessage(stepNames.step04), |
||
91 | }, |
||
92 | status: currentStep === "fit" ? "current" : myFitStatus(application), |
||
93 | }, |
||
94 | { |
||
95 | link: { |
||
96 | url: applicationReview(locale, application.id), |
||
97 | text: intl.formatMessage(stepNames.step05), |
||
98 | title: intl.formatMessage(stepNames.step05), |
||
99 | }, |
||
100 | status: currentStep === "review" ? "current" : reviewStatus(application), |
||
101 | }, |
||
102 | { |
||
103 | link: { |
||
104 | url: applicationSubmission(locale, application.id), |
||
105 | text: intl.formatMessage(stepNames.step06), |
||
106 | title: intl.formatMessage(stepNames.step06), |
||
107 | }, |
||
108 | status: |
||
109 | currentStep === "submission" |
||
110 | ? "current" |
||
111 | : submissionStatus(application), |
||
112 | }, |
||
117 |