Conditions | 7 |
Total Lines | 73 |
Code Lines | 70 |
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 | package com.osomapps.pt.xlsx; |
||
70 | private void fillProgram(XSSFSheet programSheet, InProgram inProgram) { |
||
71 | for (int index = 0; index < 16; index += 1) { |
||
72 | fillCell(programSheet, 2 + index, 3, ""); |
||
73 | fillCell(programSheet, 2 + index, 4, ""); |
||
74 | fillCell(programSheet, 2 + index, 5, ""); |
||
75 | } |
||
76 | for (int index = 0; index < inProgram.getInWorkouts().size(); index += 1) { |
||
77 | fillCell( |
||
78 | programSheet, |
||
79 | 2 + index, |
||
80 | 3, |
||
81 | "Goal " + (inProgram.getInWorkouts().get(index).getGoal_index() + 1)); |
||
82 | fillCell( |
||
83 | programSheet, |
||
84 | 2 + index, |
||
85 | 4, |
||
86 | inProgram.getInWorkouts().get(index).getPart_name()); |
||
87 | fillCell( |
||
88 | programSheet, |
||
89 | 2 + index, |
||
90 | 5, |
||
91 | "Workout " + (inProgram.getInWorkouts().get(index).getWorkout_index() + 1)); |
||
92 | final InWarmupWorkoutItem inWarmupWorkoutItem = |
||
93 | inProgram.getInWorkouts().get(index).getInWarmupWorkoutItems().get(0); |
||
94 | fillCell(programSheet, 2 + index, 7, inWarmupWorkoutItem.getD_exercise_name()); |
||
95 | fillCell(programSheet, 2 + index, 8, inWarmupWorkoutItem.getSpeed() + " km/h"); |
||
96 | fillCell(programSheet, 2 + index, 9, inWarmupWorkoutItem.getIncline() + "%"); |
||
97 | fillCell( |
||
98 | programSheet, |
||
99 | 2 + index, |
||
100 | 10, |
||
101 | (inWarmupWorkoutItem.getTime_in_sec() / 60) + " min"); |
||
102 | for (int index2 = 0; |
||
103 | index2 < inProgram.getInWorkouts().get(index).getInWorkoutItems().size(); |
||
104 | index2 += 1) { |
||
105 | final InWorkoutItem inWorkoutItem = |
||
106 | inProgram.getInWorkouts().get(index).getInWorkoutItems().get(index2); |
||
107 | fillCell( |
||
108 | programSheet, |
||
109 | 2 + index, |
||
110 | 11 + 7 * index2, |
||
111 | inWorkoutItem.getD_exercise_name()); |
||
112 | fillCell( |
||
113 | programSheet, |
||
114 | 2 + index, |
||
115 | 12 + 7 * index2, |
||
116 | inWorkoutItem.getInWorkoutItemSets().size()); |
||
117 | if (inWorkoutItem.getInWorkoutItemSets().get(0).getRepetitions() != null) { |
||
118 | fillCell( |
||
119 | programSheet, |
||
120 | 2 + index, |
||
121 | 13 + 7 * index2, |
||
122 | inWorkoutItem.getInWorkoutItemSets().stream() |
||
123 | .map(set -> "" + set.getRepetitions()) |
||
124 | .collect(Collectors.joining(","))); |
||
125 | } |
||
126 | if (inWorkoutItem.getInWorkoutItemSets().get(0).getTime_in_sec() != null) { |
||
127 | fillCell( |
||
128 | programSheet, |
||
129 | 2 + index, |
||
130 | 13 + 7 * index2, |
||
131 | inWorkoutItem.getInWorkoutItemSets().stream() |
||
132 | .map(set -> round(set.getTime_in_sec() / 60F) + " min") |
||
133 | .collect(Collectors.joining(","))); |
||
134 | } |
||
135 | if (inWorkoutItem.getInWorkoutItemSets().get(0).getWeight() != null) { |
||
136 | fillCell( |
||
137 | programSheet, |
||
138 | 2 + index, |
||
139 | 14 + 7 * index2, |
||
140 | inWorkoutItem.getInWorkoutItemSets().stream() |
||
141 | .map(set -> round(set.getWeight())) |
||
142 | .collect(Collectors.joining(","))); |
||
143 | } |
||
198 |