Skip to content

Commit 428b97d

Browse files
authored
Merge branch 'master' into feature/improve_code_look
2 parents 6f12753 + ff5267d commit 428b97d

File tree

236 files changed

+940
-553
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

236 files changed

+940
-553
lines changed

checkstyle.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108

109109
<!-- Checks for Naming Conventions. -->
110110
<!-- See https://checkstyle.org/checks/naming/index.html -->
111-
<!-- TODO <module name="ConstantName"/> -->
111+
<module name="ConstantName"/>
112112
<!-- TODO <module name="LocalFinalVariableName"/> -->
113113
<!-- TODO <module name="LocalVariableName"/> -->
114114
<!-- TODO <module name="MemberName"/> -->
@@ -120,7 +120,7 @@
120120

121121
<!-- Checks for imports -->
122122
<!-- See https://checkstyle.org/checks/imports/index.html -->
123-
<!-- TODO <module name="AvoidStarImport"/> -->
123+
<module name="AvoidStarImport"/>
124124
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
125125
<module name="RedundantImport"/>
126126
<module name="UnusedImports">
@@ -148,7 +148,7 @@
148148
<!-- Modifier Checks -->
149149
<!-- See https://checkstyle.org/checks/modifier/index.html -->
150150
<module name="ModifierOrder"/>
151-
<!-- TODO <module name="RedundantModifier"/> -->
151+
<module name="RedundantModifier"/>
152152

153153
<!-- Checks for blocks. You know, those {}'s -->
154154
<!-- See https://checkstyle.org/checks/blocks/index.html -->
@@ -181,7 +181,7 @@
181181

182182
<!-- Miscellaneous other checks. -->
183183
<!-- See https://checkstyle.org/checks/misc/index.html -->
184-
<!-- TODO <module name="ArrayTypeStyle"/> -->
184+
<module name="ArrayTypeStyle"/>
185185
<!-- TODO <module name="FinalParameters"/> -->
186186
<!-- TODO <module name="TodoComment"/> -->
187187
<module name="UpperEll"/>

pom.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,17 @@
117117
<plugin>
118118
<groupId>com.github.spotbugs</groupId>
119119
<artifactId>spotbugs-maven-plugin</artifactId>
120-
<version>4.8.4.0</version>
120+
<version>4.8.5.0</version>
121121
<configuration>
122122
<excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
123123
<includeTests>true</includeTests>
124+
<plugins>
125+
<plugin>
126+
<groupId>com.mebigfatguy.fb-contrib</groupId>
127+
<artifactId>fb-contrib</artifactId>
128+
<version>7.6.4</version>
129+
</plugin>
130+
</plugins>
124131
</configuration>
125132
</plugin>
126133
</plugins>

spotbugs-exclude.xml

Lines changed: 160 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
<Match>
66
<Bug pattern="EI_EXPOSE_REP2" />
77
</Match>
8-
<Match>
9-
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD" />
10-
</Match>
118
<Match>
129
<Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" />
1310
</Match>
@@ -125,4 +122,164 @@
125122
<Match>
126123
<Bug pattern="RV_ABSOLUTE_VALUE_OF_HASHCODE" />
127124
</Match>
125+
<!-- fb-contrib -->
126+
<Match>
127+
<Bug pattern="OCP_OVERLY_CONCRETE_PARAMETER" />
128+
</Match>
129+
<Match>
130+
<Bug pattern="NAB_NEEDLESS_BOOLEAN_CONSTANT_CONVERSION" />
131+
</Match>
132+
<Match>
133+
<Bug pattern="LSC_LITERAL_STRING_COMPARISON" />
134+
</Match>
135+
<Match>
136+
<Bug pattern="CE_CLASS_ENVY" />
137+
</Match>
138+
<Match>
139+
<Bug pattern="PSC_PRESIZE_COLLECTIONS" />
140+
</Match>
141+
<Match>
142+
<Bug pattern="SACM_STATIC_ARRAY_CREATED_IN_METHOD" />
143+
</Match>
144+
<Match>
145+
<Bug pattern="LUI_USE_SINGLETON_LIST" />
146+
</Match>
147+
<Match>
148+
<Bug pattern="CLI_CONSTANT_LIST_INDEX" />
149+
</Match>
150+
<Match>
151+
<Bug pattern="BED_BOGUS_EXCEPTION_DECLARATION" />
152+
</Match>
153+
<Match>
154+
<Bug pattern="CNC_COLLECTION_NAMING_CONFUSION" />
155+
</Match>
156+
<Match>
157+
<Bug pattern="TR_TAIL_RECURSION" />
158+
</Match>
159+
<Match>
160+
<Bug pattern="LII_LIST_INDEXED_ITERATING" />
161+
</Match>
162+
<Match>
163+
<Bug pattern="USBR_UNNECESSARY_STORE_BEFORE_RETURN" />
164+
</Match>
165+
<Match>
166+
<Bug pattern="MAC_MANUAL_ARRAY_COPY" />
167+
</Match>
168+
<Match>
169+
<Bug pattern="SPP_USE_ISEMPTY" />
170+
</Match>
171+
<Match>
172+
<Bug pattern="BL_BURYING_LOGIC" />
173+
</Match>
174+
<Match>
175+
<Bug pattern="OI_OPTIONAL_ISSUES_USES_IMMEDIATE_EXECUTION" />
176+
</Match>
177+
<Match>
178+
<Bug pattern="PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS" />
179+
</Match>
180+
<Match>
181+
<Bug pattern="UTWR_USE_TRY_WITH_RESOURCES" />
182+
</Match>
183+
<Match>
184+
<Bug pattern="MUI_CONTAINSKEY_BEFORE_GET" />
185+
</Match>
186+
<Match>
187+
<Bug pattern="IMC_IMMATURE_CLASS_PRINTSTACKTRACE" />
188+
</Match>
189+
<Match>
190+
<Bug pattern="UCPM_USE_CHARACTER_PARAMETERIZED_METHOD" />
191+
</Match>
192+
<Match>
193+
<Bug pattern="SUA_SUSPICIOUS_UNINITIALIZED_ARRAY" />
194+
</Match>
195+
<Match>
196+
<Bug pattern="SPP_USE_MATH_CONSTANT" />
197+
</Match>
198+
<Match>
199+
<Bug pattern="UJM_UNJITABLE_METHOD" />
200+
</Match>
201+
<Match>
202+
<Bug pattern="SEC_SIDE_EFFECT_CONSTRUCTOR" />
203+
</Match>
204+
<Match>
205+
<Bug pattern="MDM_STRING_BYTES_ENCODING" />
206+
</Match>
207+
<Match>
208+
<Bug pattern="PMB_POSSIBLE_MEMORY_BLOAT" />
209+
</Match>
210+
<Match>
211+
<Bug pattern="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" />
212+
</Match>
213+
<Match>
214+
<Bug pattern="IOI_USE_OF_FILE_STREAM_CONSTRUCTORS" />
215+
</Match>
216+
<Match>
217+
<Bug pattern="UP_UNUSED_PARAMETER" />
218+
</Match>
219+
<Match>
220+
<Bug pattern="DSOC_DUBIOUS_SET_OF_COLLECTIONS" />
221+
</Match>
222+
<Match>
223+
<Bug pattern="NAB_NEEDLESS_BOX_TO_UNBOX" />
224+
</Match>
225+
<Match>
226+
<Bug pattern="FPL_FLOATING_POINT_LOOPS" />
227+
</Match>
228+
<Match>
229+
<Bug pattern="ITU_INAPPROPRIATE_TOSTRING_USE" />
230+
</Match>
231+
<Match>
232+
<Bug pattern="DMC_DUBIOUS_MAP_COLLECTION" />
233+
</Match>
234+
<Match>
235+
<Bug pattern="SPP_PASSING_THIS_AS_PARM" />
236+
</Match>
237+
<Match>
238+
<Bug pattern="FCBL_FIELD_COULD_BE_LOCAL" />
239+
</Match>
240+
<Match>
241+
<Bug pattern="ENMI_EQUALS_ON_ENUM" />
242+
</Match>
243+
<Match>
244+
<Bug pattern="NAB_NEEDLESS_BOXING_PARSE" />
245+
</Match>
246+
<Match>
247+
<Bug pattern="IMC_IMMATURE_CLASS_VAR_NAME" />
248+
</Match>
249+
<Match>
250+
<Bug pattern="CFS_CONFUSING_FUNCTION_SEMANTICS" />
251+
</Match>
252+
<Match>
253+
<Bug pattern="PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS" />
254+
</Match>
255+
<Match>
256+
<Bug pattern="FCCD_FIND_CLASS_CIRCULAR_DEPENDENCY" />
257+
</Match>
258+
<Match>
259+
<Bug pattern="LEST_LOST_EXCEPTION_STACK_TRACE" />
260+
</Match>
261+
<Match>
262+
<Bug pattern="PL_PARALLEL_LISTS" />
263+
</Match>
264+
<Match>
265+
<Bug pattern="PCAIL_POSSIBLE_CONSTANT_ALLOCATION_IN_LOOP" />
266+
</Match>
267+
<Match>
268+
<Bug pattern="STT_STRING_PARSING_A_FIELD" />
269+
</Match>
270+
<Match>
271+
<Bug pattern="IMC_IMMATURE_CLASS_BAD_SERIALVERSIONUID" />
272+
</Match>
273+
<Match>
274+
<Bug pattern="SUI_CONTAINS_BEFORE_ADD" />
275+
</Match>
276+
<Match>
277+
<Bug pattern="DRE_DECLARED_RUNTIME_EXCEPTION" />
278+
</Match>
279+
<Match>
280+
<Bug pattern="SLS_SUSPICIOUS_LOOP_SEARCH" />
281+
</Match>
282+
<Match>
283+
<Bug pattern="SPP_TOSTRING_ON_STRING" />
284+
</Match>
128285
</FindBugsFilter>

src/main/java/com/thealgorithms/backtracking/AllPathsFromSourceToTarget.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
/**Wikipedia link -> https://en.wikipedia.org/wiki/Shortest_path_problem */
99
package com.thealgorithms.backtracking;
1010

11-
import java.util.*;
11+
import java.util.ArrayList;
12+
import java.util.List;
1213

1314
public class AllPathsFromSourceToTarget {
1415

src/main/java/com/thealgorithms/backtracking/ArrayCombination.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.thealgorithms.backtracking;
22

3-
import java.util.*;
3+
import java.util.List;
4+
import java.util.TreeSet;
45

56
/**
67
* Finds all permutations of 1...n of length k

src/main/java/com/thealgorithms/backtracking/Combination.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.thealgorithms.backtracking;
22

3-
import java.util.*;
3+
import java.util.Arrays;
4+
import java.util.LinkedList;
5+
import java.util.List;
6+
import java.util.TreeSet;
47

58
/**
69
* Finds all permutations of given array

src/main/java/com/thealgorithms/backtracking/KnightsTour.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.thealgorithms.backtracking;
22

3-
import java.util.*;
3+
import java.util.ArrayList;
4+
import java.util.Comparator;
5+
import java.util.List;
46

57
/*
68
* Problem Statement: -
@@ -26,8 +28,8 @@
2628
*/
2729
public class KnightsTour {
2830

29-
private static final int base = 12;
30-
private static final int[][] moves = {
31+
private static final int BASE = 12;
32+
private static final int[][] MOVES = {
3133
{1, -2},
3234
{2, -1},
3335
{2, 1},
@@ -41,19 +43,19 @@ public class KnightsTour {
4143
private static int total; // total squares in chess
4244

4345
public static void main(String[] args) {
44-
grid = new int[base][base];
45-
total = (base - 4) * (base - 4);
46+
grid = new int[BASE][BASE];
47+
total = (BASE - 4) * (BASE - 4);
4648

47-
for (int r = 0; r < base; r++) {
48-
for (int c = 0; c < base; c++) {
49-
if (r < 2 || r > base - 3 || c < 2 || c > base - 3) {
49+
for (int r = 0; r < BASE; r++) {
50+
for (int c = 0; c < BASE; c++) {
51+
if (r < 2 || r > BASE - 3 || c < 2 || c > BASE - 3) {
5052
grid[r][c] = -1;
5153
}
5254
}
5355
}
5456

55-
int row = 2 + (int) (Math.random() * (base - 4));
56-
int col = 2 + (int) (Math.random() * (base - 4));
57+
int row = 2 + (int) (Math.random() * (BASE - 4));
58+
int col = 2 + (int) (Math.random() * (BASE - 4));
5759

5860
grid[row][col] = 1;
5961

@@ -95,7 +97,7 @@ private static boolean solve(int row, int column, int count) {
9597
private static List<int[]> neighbors(int row, int column) {
9698
List<int[]> neighbour = new ArrayList<>();
9799

98-
for (int[] m : moves) {
100+
for (int[] m : MOVES) {
99101
int x = m[0];
100102
int y = m[1];
101103
if (grid[row + y][column + x] == 0) {
@@ -109,7 +111,7 @@ private static List<int[]> neighbors(int row, int column) {
109111
// Returns the total count of neighbors
110112
private static int countNeighbors(int row, int column) {
111113
int num = 0;
112-
for (int[] m : moves) {
114+
for (int[] m : MOVES) {
113115
if (grid[row + m[1]][column + m[0]] == 0) {
114116
num++;
115117
}

src/main/java/com/thealgorithms/backtracking/MColoring.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.thealgorithms.backtracking;
22

3-
import java.util.*;
3+
import java.util.ArrayList;
4+
import java.util.HashSet;
5+
import java.util.LinkedList;
6+
import java.util.Queue;
7+
import java.util.Set;
48

59
/**
610
* @author Bama Charan Chhandogi (https://github.com/BamaCharanChhandogi)

src/main/java/com/thealgorithms/ciphers/AESEncryption.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
import java.security.InvalidAlgorithmParameterException;
44
import java.security.InvalidKeyException;
55
import java.security.NoSuchAlgorithmException;
6-
import javax.crypto.*;
6+
import javax.crypto.BadPaddingException;
7+
import javax.crypto.Cipher;
8+
import javax.crypto.IllegalBlockSizeException;
9+
import javax.crypto.KeyGenerator;
10+
import javax.crypto.NoSuchPaddingException;
11+
import javax.crypto.SecretKey;
712
import javax.crypto.spec.GCMParameterSpec;
813

914
/**

src/main/java/com/thealgorithms/ciphers/DES.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
public class DES {
99

1010
private String key;
11-
private String subKeys[];
11+
private String[] subKeys;
1212

1313
private void sanitize(String key) {
1414
int length = key.length();
@@ -78,7 +78,7 @@ private String[] getSubkeys(String originalKey) {
7878
for (i = 0; i < 56; i++) {
7979
permutedKey.append(originalKey.charAt(PC1[i] - 1));
8080
}
81-
String subKeys[] = new String[16];
81+
String[] subKeys = new String[16];
8282
String initialPermutedKey = permutedKey.toString();
8383
String C0 = initialPermutedKey.substring(0, 28), D0 = initialPermutedKey.substring(28);
8484

@@ -159,7 +159,7 @@ private String feistel(String messageBlock, String key) {
159159
return permutedString.toString();
160160
}
161161

162-
private String encryptBlock(String message, String keys[]) {
162+
private String encryptBlock(String message, String[] keys) {
163163
StringBuilder permutedMessage = new StringBuilder();
164164
int i;
165165
for (i = 0; i < 64; i++) {
@@ -184,8 +184,8 @@ private String encryptBlock(String message, String keys[]) {
184184
}
185185

186186
// To decode, we follow the same process as encoding, but with reversed keys
187-
private String decryptBlock(String message, String keys[]) {
188-
String reversedKeys[] = new String[keys.length];
187+
private String decryptBlock(String message, String[] keys) {
188+
String[] reversedKeys = new String[keys.length];
189189
for (int i = 0; i < keys.length; i++) {
190190
reversedKeys[i] = keys[keys.length - i - 1];
191191
}
@@ -230,7 +230,7 @@ public String decrypt(String message) {
230230
for (i = 0; i < l; i += 64) {
231231
String block = message.substring(i, i + 64);
232232
String result = decryptBlock(block.toString(), subKeys);
233-
byte res[] = new byte[8];
233+
byte[] res = new byte[8];
234234
for (j = 0; j < 64; j += 8) {
235235
res[j / 8] = (byte) Integer.parseInt(result.substring(j, j + 8), 2);
236236
}

0 commit comments

Comments
 (0)