Skip to content

Commit

Permalink
Fixing SonarLint recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
RobFaustLZ committed Jun 4, 2024
1 parent ab43576 commit d6ea586
Show file tree
Hide file tree
Showing 17 changed files with 20 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public abstract class AComponent implements Cloneable {
/**
* Parameterless constructor
*/
public AComponent() { this(null); }
protected AComponent() { this(null); }

/**
* Cloning constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Getter
Expand All @@ -26,7 +25,7 @@ public abstract class AContainer extends AComponent
/**
* Parameterless constructor
*/
public AContainer() { this(null); }
protected AContainer() { this(null); }

/**
* Cloning constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract class AFontComponent extends AComponent
/**
* Parameterless constructor
*/
public AFontComponent() { this(null); }
protected AFontComponent() { this(null); }

/**
* Cloning constructor
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/com/labelzoom/api/model/components/CLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ private Map<String, CLayer> getLayerMap()
}
}
}
if (!layerMap.containsKey(DEFAULT_LAYER_NAME))
{
layerMap.put(DEFAULT_LAYER_NAME, new CLayer(DEFAULT_LAYER_NAME));
}
layerMap.computeIfAbsent(DEFAULT_LAYER_NAME, CLayer::new);
return layerMap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

public interface IDynamicField extends Cloneable, IDataField
{
Pattern SIMPLE_EXPRESSION_PATTERN = Pattern.compile("\"\\$\\{([A-Za-z0-9_]+)\\}\"");
Pattern VARIABLE_EXPRESSION_PATTERN = Pattern.compile("\\$\\{([A-Za-z0-9_]+)\\}");
Pattern VARIABLE_NAME_PATTERN = Pattern.compile("^([A-Za-z0-9_]+)$");
Pattern SIMPLE_EXPRESSION_PATTERN = Pattern.compile("\"\\$\\{(\\w+)\\}\"");
Pattern VARIABLE_EXPRESSION_PATTERN = Pattern.compile("\\$\\{(\\w+)\\}");
Pattern VARIABLE_NAME_PATTERN = Pattern.compile("^(\\w+)$");

void setExpression(String expression);
String getExpression();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public enum BarcodeStyle
/**
* Parameterless constructor
*/
public ABarcode() { this(null, false); }
protected ABarcode() { this(null, false); }

/**
* Cloning constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public enum HumanReadableStyle
/**
* Parameterless constructor
*/
public ALinearBarcode() { this(null, false); }
protected ALinearBarcode() { this(null, false); }

/**
* Cloning constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
public abstract class A2DBarcode extends ABarcode
{
public A2DBarcode() { this(null, false); }
protected A2DBarcode() { this(null, false); }

protected A2DBarcode(final A2DBarcode original, final boolean cloneData)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/

import com.labelzoom.api.model.components.AComponent;
import com.labelzoom.api.model.components.barcodes.ABarcode;
import lombok.Getter;
import lombok.Setter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/

import com.labelzoom.api.model.components.AComponent;
import com.labelzoom.api.model.components.barcodes.ABarcode;
import lombok.Getter;
import lombok.Setter;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/labelzoom/api/util/DpiUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public DpiUtility(final int sourceDpi, final int targetDpi, final int sourceFont

private float applyResize(final float sourceValue)
{
return (float)(((double)sourceValue) * scalingFactor);
return (float)(sourceValue * scalingFactor);
}

private int applyResize(final int sourceValue)
Expand All @@ -44,7 +44,7 @@ private int applyResize(final int sourceValue)

private float applyFontResize(final float sourceValue)
{
return (float)(((double)sourceValue) * fontScalingFactor);
return (float)(sourceValue * fontScalingFactor);
}

public CLabel resizeLabel(final CLabel label)
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/com/labelzoom/api/util/HSLColor.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,7 @@ public float getSaturation()

public String toString()
{
String toString =
"HSLColor[h=" + hsl[0] +
",s=" + hsl[1] +
",l=" + hsl[2] +
",alpha=" + alpha + "]";

return toString;
return String.format("HSLColor[h=%f,s=%f,l=%f,alpha=%f]", hsl[0], hsl[1], hsl[2], alpha);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/labelzoom/api/util/ImageUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class ImageUtils
private static final int BLACK = Color.BLACK.getRGB();
private static final int WHITE = Color.WHITE.getRGB();

private ImageUtils() {}

public static BufferedImage cloneImage(final BufferedImage image)
{
// Clone original image
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/labelzoom/api/util/RotationUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

public class RotationUtility
{
private RotationUtility() {}

public static int normalizeRotation(float degrees) { return normalizeRotation(Math.round(degrees)); }

public static int normalizeRotation(int degrees)
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/labelzoom/api/DeepCopyTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import static org.junit.jupiter.api.Assertions.*;

public class DeepCopyTests
class DeepCopyTests
{
private final ObjectMapper objectMapper = new ObjectMapper();

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/labelzoom/api/util/ImageUtilsTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import static org.junit.jupiter.api.Assertions.*;

public class ImageUtilsTests
class ImageUtilsTests
{
private final float DEFAULT_TOLERANCE = 0.1f;

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/labelzoom/api/util/LazyTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

public class LazyTests
class LazyTests
{
@Test
void testLazy()
Expand Down

0 comments on commit d6ea586

Please sign in to comment.