Skip to content

Commit

Permalink
Fix style warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pnatashap committed Mar 18, 2024
1 parent 5ac197f commit c577025
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/main/java/org/cactoos/bytes/BytesOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
*
* @since 0.12
*/
@SuppressWarnings("PMD.OnlyOneConstructorShouldDoInitialization")
public final class BytesOf implements Bytes {

/**
Expand Down Expand Up @@ -263,6 +264,7 @@ public BytesOf(final Throwable error, final Charset charset) {
* @param error The exception to serialize
* @param charset Charset
*/
@SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors")
public BytesOf(final Throwable error, final CharSequence charset) {
this(
() -> {
Expand Down Expand Up @@ -304,6 +306,7 @@ public BytesOf(final StackTraceElement[] strace, final Charset charset) {
* @param charset Charset
* @since 0.29
*/
@SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors")
public BytesOf(final StackTraceElement[] strace,
final CharSequence charset) {
this(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
* @param <X> Element type
* @since 0.23
*/
@SuppressWarnings("PMD.TooManyMethods")
public abstract class CollectionEnvelope<X>
extends IterableEnvelope<X> implements Collection<X> {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/iterable/IterableOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public Iterator<X> iterator() {

@Override
@SuppressFBWarnings("EQ_UNUSUAL")
@SuppressWarnings (value = "unchecked")
@SuppressWarnings("unchecked")
public boolean equals(final Object other) {
return new Unchecked<>(
new Or(
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/cactoos/iterable/Synced.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package org.cactoos.iterable;

import java.util.Iterator;
import org.cactoos.iterator.Mapped;

/**
* Synchronized iterable.
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/cactoos/list/ListOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public ListOf(final Iterator<? extends T> src) {
* Ctor.
* @param src An {@link Iterable}
*/
@SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors")
public ListOf(final Iterable<? extends T> src) {
super(new LinkedList<>());
src.forEach(super::add);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/cactoos/proc/RunnableOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public RunnableOf(final Scalar<?> scalar) {
* @param callable The callable
* @since 0.53
*/
@SuppressWarnings("PMD.AvoidCatchingGenericException")
public RunnableOf(final Callable<?> callable) {
this(
() -> {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/cactoos/scalar/LengthOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public LengthOf(final Input input) {
* @param input The input
* @param max Buffer size
*/
@SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors")
public LengthOf(final Input input, final int max) {
this(() -> {
if (max == 0) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/cactoos/scalar/PropertiesOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.cactoos.Text;
import org.cactoos.io.InputOf;
import org.cactoos.iterable.IterableOf;
import org.cactoos.iterable.Mapped;
import org.cactoos.map.MapEntry;
import org.cactoos.map.MapOf;
import org.cactoos.text.TextOf;
Expand All @@ -44,6 +43,7 @@
*
* @since 0.12
*/
@SuppressWarnings("PMD.OnlyOneConstructorShouldDoInitialization")
public final class PropertiesOf implements Scalar<Properties> {

/**
Expand Down Expand Up @@ -71,6 +71,7 @@ public PropertiesOf(final Text text) {
* Ctor.
* @param input Input
*/
@SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors")
public PropertiesOf(final Input input) {
this(
() -> {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/cactoos/set/SetOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public SetOf(final T... array) {
* Ctor.
* @param src An {@link Iterable}
*/
@SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors")
public SetOf(final Iterable<? extends T> src) {
super(new HashSet<>());
src.forEach(super::add);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/cactoos/text/FormattedText.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public FormattedText(
* @param locale Format locale
* @param args Arguments
*/
@SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors")
public FormattedText(
final Text ptn,
final Locale locale,
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/text/HexOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public HexOf(final Bytes bytes) {
final byte[] bts = bytes.asBytes();
final char[] hex = new char[bts.length * 2];
int chr = -1;
for (int idx = 0; idx < bts.length; ++idx) {
final int value = 0xff & bts[idx];
for (final byte b: bts) {
final int value = 0xff & b;
hex[++chr] = HexOf.HEX_CHARS[value >>> 4];
hex[++chr] = HexOf.HEX_CHARS[value & 0x0f];
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/cactoos/func/SolidBiFuncTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final class SolidBiFuncTest {
@Test
void testThatFuncIsSynchronized() {
final int threads = 100;
final int[] shared = new int[]{0};
final int[] shared = {0};
final BiFunc<Integer, Integer, Boolean> testable =
new SolidBiFunc<>(
(first, second) -> {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/cactoos/scalar/CheckedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void usesContravarianceOnResultType() throws Exception {
new Assertion<>(
"Must use contravariance on result",
new Checked<CharSequence, IOException>(
() -> new String("contravariance"),
() -> "contravariance",
IOException::new
).value(),
new IsEqual<>("contravariance")
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/cactoos/text/FormattedTextTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void formatsTextWithObjects() {
new FormattedText(
new TextOf("%d. Number as %s"),
1,
new String("string")
"string"
),
new HasString("1. Number as string")
).affirm();
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/cactoos/text/TextOfTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void readsEncodedArrayOfCharsIntoText() {

@Test
void readsAnArrayOfBytes() {
final byte[] bytes = new byte[]{(byte) 0xCA, (byte) 0xFE};
final byte[] bytes = {(byte) 0xCA, (byte) 0xFE};
new Assertion<>(
"Can't read array of bytes",
new TextOf(
Expand Down

0 comments on commit c577025

Please sign in to comment.