Skip to content

Commit c221fa2

Browse files
committed
Quality & typos fixes
1 parent b9e3067 commit c221fa2

File tree

11 files changed

+54
-31
lines changed

11 files changed

+54
-31
lines changed

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@
153153
<version>3.3</version>
154154
<configuration>
155155
<compilerArgs>
156-
<arg>-Xlint</arg>
156+
<arg>-Werror</arg>
157+
<arg>-Xlint:all</arg>
157158
</compilerArgs>
158159
</configuration>
159160
</plugin>

src/main/java/pl/wavesoftware/eid/exceptions/Eid.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ public static UniqIdGenerator setUniqIdGenerator(UniqIdGenerator uniqIdGenerator
136136
*/
137137
public static String setFormat(String format) {
138138
validateFormat(format, FORMAT_NUM_SPEC);
139-
String prevoiusly = Eid.format;
139+
String previously = Eid.format;
140140
Eid.format = format;
141-
return prevoiusly;
141+
return previously;
142142
}
143143

144144
/**
@@ -191,7 +191,7 @@ public String getUniq() {
191191
return uniq;
192192
}
193193

194-
static void validateFormat(String format, int numSpecifiers) {
194+
private static void validateFormat(String format, int numSpecifiers) {
195195
if (format == null) {
196196
throw new IllegalArgumentException("Format can't be null, but just received one");
197197
}
@@ -229,7 +229,7 @@ private static final class StdUniqIdGenerator implements UniqIdGenerator {
229229
private final Random random;
230230

231231
private StdUniqIdGenerator() {
232-
this.random = getUnsecureFastRandom();
232+
this.random = getUnsecuredFastRandom();
233233
}
234234

235235
@Override
@@ -241,7 +241,7 @@ public String generateUniqId() {
241241
}
242242

243243
@SuppressWarnings("squid:S2245")
244-
private Random getUnsecureFastRandom() {
244+
private Random getUnsecuredFastRandom() {
245245
return new Random(System.currentTimeMillis());
246246
}
247247

src/main/java/pl/wavesoftware/eid/exceptions/EidContainer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*
2121
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
2222
*/
23+
@SuppressWarnings("WeakerAccess")
2324
public interface EidContainer {
2425

2526
/**

src/main/java/pl/wavesoftware/eid/exceptions/EidIllegalArgumentException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717

1818
/**
1919
* <strong>This class shouldn't be used in any public API or library.</strong> It is designed to be used for in-house development
20-
* of end user applications which will report Bugs in standarized error pages or post them to issue tracker.
20+
* of end user applications which will report Bugs in standardized error pages or post them to issue tracker.
2121
* <p>
2222
* This is Eid version of {@link IllegalArgumentException}
2323
*
2424
* @see IllegalArgumentException
2525
* @see EidRuntimeException
2626
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
2727
*/
28+
@SuppressWarnings("unused")
2829
public class EidIllegalArgumentException extends EidRuntimeException {
2930

3031
private static final long serialVersionUID = -9876432123423427L;

src/main/java/pl/wavesoftware/eid/exceptions/EidIllegalStateException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717

1818
/**
1919
* <strong>This class shouldn't be used in any public API or library.</strong> It is designed to be used for in-house development
20-
* of end user applications which will report Bugs in standarized error pages or post them to issue tracker.
20+
* of end user applications which will report Bugs in standardized error pages or post them to issue tracker.
2121
* <p>
2222
* This id Eid version of {@link IllegalStateException}
2323
*
2424
* @see IllegalStateException
2525
* @see EidRuntimeException
2626
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
2727
*/
28+
@SuppressWarnings("unused")
2829
public class EidIllegalStateException extends EidRuntimeException {
2930

3031
private static final long serialVersionUID = -9876432123423443L;

src/main/java/pl/wavesoftware/eid/exceptions/EidIndexOutOfBoundsException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717

1818
/**
1919
* <strong>This class shouldn't be used in any public API or library.</strong> It is designed to be used for in-house development
20-
* of end user applications which will report Bugs in standarized error pages or post them to issue tracker.
20+
* of end user applications which will report Bugs in standardized error pages or post them to issue tracker.
2121
* <p>
2222
* This id Eid version of {@link IndexOutOfBoundsException}
2323
*
2424
* @see IndexOutOfBoundsException
2525
* @see EidRuntimeException
2626
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
2727
*/
28+
@SuppressWarnings("unused")
2829
public class EidIndexOutOfBoundsException extends EidRuntimeException {
2930

3031
private static final long serialVersionUID = -9876432123423451L;

src/main/java/pl/wavesoftware/eid/exceptions/EidNullPointerException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717

1818
/**
1919
* <strong>This class shouldn't be used in any public API or library.</strong> It is designed to be used for in-house development
20-
* of end user applications which will report Bugs in standarized error pages or post them to issue tracker.
20+
* of end user applications which will report Bugs in standardized error pages or post them to issue tracker.
2121
* <p>
2222
* This id Eid version of {@link NullPointerException}
2323
*
2424
* @see NullPointerException
2525
* @see EidRuntimeException
2626
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
2727
*/
28+
@SuppressWarnings("unused")
2829
public class EidNullPointerException extends EidRuntimeException {
2930

3031
private static final long serialVersionUID = -9876432123423469L;

src/main/java/pl/wavesoftware/eid/exceptions/EidRuntimeException.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
/**
1919
* <strong>This class shouldn't be used in any public API or library.</strong> It is designed to be used for in-house development
20-
* of end user applications which will report Bugs in standarized error pages or post them to issue tracker.
20+
* of end user applications which will report Bugs in standardized error pages or post them to issue tracker.
2121
* <p>
2222
* This exception class is baseline of all Eid runtime exception classes. It is designed to ease of use and provide strict ID for
2323
* given Exception usage. This approach speed up development of large application and helps support teams to by giving the both
@@ -54,12 +54,13 @@ public EidRuntimeException(String eid, String ref) {
5454
* Constructs a new runtime exception with the specified cause, a exception Id and detail message of <tt>eid.toString() + " =>
5555
* " + (cause==null ? null : cause.toString())</tt>
5656
* (which typically contains the class and detail message of
57-
* <tt>cause</tt>). This constructor is useful for runtime exceptions that are little more than wrappers for other throwables.
57+
* <tt>cause</tt>). This constructor is useful for runtime exceptions that are little more than wrappers for other throwable.
5858
*
5959
* @param eid exception ID
6060
* @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A <tt>null</tt>
6161
* value is permitted, and indicates that the cause is nonexistent or unknown.)
6262
*/
63+
@SuppressWarnings("WeakerAccess")
6364
public EidRuntimeException(String eid, Throwable cause) {
6465
this(new Eid(eid), cause);
6566
}
@@ -72,6 +73,7 @@ public EidRuntimeException(String eid, Throwable cause) {
7273
* @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A <tt>null</tt> value is
7374
* permitted, and indicates that the cause is nonexistent or unknown.)
7475
*/
76+
@SuppressWarnings("WeakerAccess")
7577
public EidRuntimeException(String eid, String ref, Throwable cause) {
7678
this(new Eid(eid, ref), cause);
7779
}
@@ -81,6 +83,7 @@ public EidRuntimeException(String eid, String ref, Throwable cause) {
8183
*
8284
* @param id exception ID
8385
*/
86+
@SuppressWarnings("WeakerAccess")
8487
public EidRuntimeException(Eid id) {
8588
super(id.toString());
8689
eid = id;

src/main/java/pl/wavesoftware/eid/utils/EidPreconditions.java

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
* <p>
8787
* Using functional blocks to handle operations, that are intended to operate properly, simplify the code and makes it more
8888
* readable. It's also good way to deal with untested, uncovered {@code catch} blocks. It's easy and gives developers nice way of
89-
* dealing with countless operations that supose to work as intended.
89+
* dealing with countless operations that suppose to work as intended.
9090
*
9191
* <p>
9292
* Example:
@@ -113,29 +113,31 @@ protected EidPreconditions() {
113113
/**
114114
* Ensures the truth of an expression involving one or more parameters to the calling method.
115115
*
116-
* @param expression ({@link Nonnull}) a boolean expression
116+
* @param expression ({@link Nullable}) a boolean expression
117117
* @param eid ({@link Nonnull}) the exception ID to use if the check fails; will be converted to
118118
* {@link pl.wavesoftware.eid.exceptions.Eid}
119119
* @throws EidIllegalArgumentException if {@code expression} is false
120+
* @throws EidNullPointerException if {@code expression} is null
120121
*/
121-
public static void checkArgument(@Nonnull boolean expression, @Nonnull String eid) {
122+
public static void checkArgument(@Nullable Boolean expression, @Nonnull String eid) {
122123
String checkedEid = checkNotNull(eid);
123-
if (!expression) {
124+
if (!checkNotNull(expression, checkedEid)) {
124125
throw new EidIllegalArgumentException(new Eid(checkedEid));
125126
}
126127
}
127128

128129
/**
129130
* Ensures the truth of an expression involving one or more parameters to the calling method.
130131
*
131-
* @param expression ({@link Nonnull}) a boolean expression
132+
* @param expression ({@link Nullable}) a boolean expression
132133
* @param eid ({@link Nonnull}) the exception ID to use if the check fails; will be converted to
133134
* {@link pl.wavesoftware.eid.exceptions.Eid}
134135
* @throws EidIllegalArgumentException if {@code expression} is false
136+
* @throws EidNullPointerException if {@code expression} is null
135137
*/
136-
public static void checkArgument(@Nonnull boolean expression, @Nonnull Eid eid) {
138+
public static void checkArgument(@Nullable Boolean expression, @Nonnull Eid eid) {
137139
Eid checkedEid = checkNotNull(eid);
138-
if (!expression) {
140+
if (!checkNotNull(expression, checkedEid)) {
139141
throw new EidIllegalArgumentException(checkedEid);
140142
}
141143
}
@@ -144,14 +146,15 @@ public static void checkArgument(@Nonnull boolean expression, @Nonnull Eid eid)
144146
* Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the
145147
* calling method.
146148
*
147-
* @param expression a boolean expression
148-
* @param eid the exception message to use if the check fails; will be converted to a string using
149+
* @param expression ({@link Nullable}) a boolean expression
150+
* @param eid ({@link Nonnull}) the exception message to use if the check fails; will be converted to a string using
149151
* {@link String#valueOf(Object)}
150152
* @throws EidIllegalStateException if {@code expression} is false
153+
* @throws EidNullPointerException if {@code expression} is null
151154
*/
152-
public static void checkState(@Nonnull boolean expression, @Nonnull String eid) {
155+
public static void checkState(@Nullable Boolean expression, @Nonnull String eid) {
153156
String checkedEid = checkNotNull(eid);
154-
if (!expression) {
157+
if (!checkNotNull(expression, checkedEid)) {
155158
throw new EidIllegalStateException(new Eid(checkedEid));
156159
}
157160
}
@@ -160,14 +163,14 @@ public static void checkState(@Nonnull boolean expression, @Nonnull String eid)
160163
* Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the
161164
* calling method.
162165
*
163-
* @param expression a boolean expression
164-
* @param eid the exception message to use if the check fails; will be converted to a string using
166+
* @param expression ({@link Nullable}) a boolean expression
167+
* @param eid ({@link Nonnull}) the exception message to use if the check fails; will be converted to a string using
165168
* {@link String#valueOf(Object)}
166169
* @throws EidIllegalStateException if {@code expression} is false
167170
*/
168-
public static void checkState(@Nonnull boolean expression, @Nonnull Eid eid) {
171+
public static void checkState(@Nullable Boolean expression, @Nonnull Eid eid) {
169172
Eid checkedEid = checkNotNull(eid);
170-
if (!expression) {
173+
if (!checkNotNull(expression, checkedEid)) {
171174
throw new EidIllegalStateException(checkedEid);
172175
}
173176
}
@@ -221,7 +224,6 @@ public static <T> T checkNotNull(@Nullable T reference, @Nonnull Eid eid) {
221224
* @throws EidIndexOutOfBoundsException if {@code index} is negative or is not less than {@code size}
222225
* @throws EidIllegalArgumentException if {@code size} is negative
223226
*/
224-
@Nonnull
225227
public static int checkElementIndex(int index, int size, @Nonnull String eid) {
226228
String checkedEid = checkNotNull(eid);
227229
if (size < 0) {
@@ -245,7 +247,6 @@ public static int checkElementIndex(int index, int size, @Nonnull String eid) {
245247
* @throws EidIndexOutOfBoundsException if {@code index} is negative or is not less than {@code size}
246248
* @throws EidIllegalArgumentException if {@code size} is negative
247249
*/
248-
@Nonnull
249250
public static int checkElementIndex(int index, int size, @Nonnull Eid eid) {
250251
Eid checkedEid = checkNotNull(eid);
251252
if (size < 0) {
@@ -350,8 +351,12 @@ public interface RiskyCode<R> {
350351
R execute() throws Exception;
351352
}
352353

354+
private static boolean isNull(@Nullable Object reference) {
355+
return reference == null;
356+
}
357+
353358
private static <T> T checkNotNull(@Nullable T reference) {
354-
if (reference == null) {
359+
if (isNull(reference)) {
355360
throw new IllegalArgumentException("Pass not-null Eid to EidPreconditions first!");
356361
}
357362
return reference;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
unset MAVEN_OPTS
3+
unset JAVA_TOOL_OPTIONS
4+
exec mvn -Pci sonar:sonar \
5+
-DskipTests \
6+
-Dsonar.language=java \
7+
-Dsonar.analysis.mode=incremental \
8+
-Dsonar.host.url=https://sonar.wavesoftware.pl \
9+
-Dsonar.preview.excludePlugins=buildstability,devcockpit,pdfreport,report,views,jira,buildbreaker,issueassign,scmstats

0 commit comments

Comments
 (0)