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"; |
||
66 | |||
67 | export function makeProgressBarSteps( |
||
68 | applicationId: number, |
||
69 | application: Application | null, |
||
70 | intl: IntlShape, |
||
71 | currentStep: |
||
72 | | "welcome" |
||
73 | | "basic" |
||
74 | | "experience" |
||
75 | | "skills" |
||
76 | | "fit" |
||
77 | | "review" |
||
78 | | "submission" |
||
79 | | "other", |
||
80 | ): ProgressBarProps["steps"] { |
||
81 | const locale = getLocale(intl.locale); |
||
82 | return [ |
||
83 | { |
||
84 | link: { |
||
85 | url: applicationBasic(locale, applicationId), |
||
86 | text: intl.formatMessage(stepNames.step01), |
||
87 | title: intl.formatMessage(stepNames.step01), |
||
88 | }, |
||
89 | status: |
||
90 | currentStep === "basic" ? "current" : basicInfoStatus(application), |
||
91 | }, |
||
92 | { |
||
93 | link: { |
||
94 | url: applicationExperienceIntro(locale, applicationId), |
||
95 | text: intl.formatMessage(stepNames.step02), |
||
96 | title: intl.formatMessage(stepNames.step02), |
||
97 | }, |
||
98 | status: |
||
99 | currentStep === "experience" |
||
100 | ? "current" |
||
101 | : experienceStatus(application), |
||
102 | }, |
||
103 | { |
||
104 | link: { |
||
105 | url: applicationSkills(locale, applicationId), |
||
106 | text: intl.formatMessage(stepNames.step03), |
||
107 | title: intl.formatMessage(stepNames.step03), |
||
108 | }, |
||
109 | status: currentStep === "skills" ? "current" : skillsStatus(application), |
||
110 | }, |
||
111 | { |
||
112 | link: { |
||
113 | url: applicationFit(locale, applicationId), |
||
114 | text: intl.formatMessage(stepNames.step04), |
||
115 | title: intl.formatMessage(stepNames.step04), |
||
116 | }, |
||
117 | status: currentStep === "fit" ? "current" : myFitStatus(application), |
||
118 | }, |
||
119 | { |
||
120 | link: { |
||
121 | url: applicationReview(locale, applicationId), |
||
122 | text: intl.formatMessage(stepNames.step05), |
||
123 | title: intl.formatMessage(stepNames.step05), |
||
124 | }, |
||
125 | status: currentStep === "review" ? "current" : reviewStatus(application), |
||
126 | }, |
||
127 | { |
||
128 | link: { |
||
129 | url: applicationSubmission(locale, applicationId), |
||
130 | text: intl.formatMessage(stepNames.step06), |
||
131 | title: intl.formatMessage(stepNames.step06), |
||
132 | }, |
||
133 | status: |
||
134 | currentStep === "submission" |
||
135 | ? "current" |
||
136 | : submissionStatus(application), |
||
137 | }, |
||
142 |