Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/scripts/generate-quality-report.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,10 @@ def _is_exempt(f: Finding) -> bool:
"AssignmentInOperand",
"EmptyControlStatement",
"ForLoopCanBeForeach",
"UnusedFormalParameter"
"UnusedFormalParameter",
"SwitchStmtsShouldHaveDefault",
"UnconditionalIfStatement",
"SimplifyConditional"
}
violations = [f for f in pmd.findings if f.rule in forbidden_pmd_rules]
if violations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,9 @@ private String getQualityString() {
return "Low quality";
case QUALITY_HIGH:
return "High quality";
default:
return "";
}
return "";
}

private String getMaxFileSizeString() {
Expand Down
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/charts/ChartComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public class ChartComponent extends Component {
public ChartComponent(AbstractChart chart) {
setUIIDFinal("ChartComponent");
this.chart = chart;
if (chart != null && chart instanceof XYChart) {
if (chart instanceof XYChart) {
XYChart xyChart = (XYChart) chart;
zoomEnabled = xyChart.getRenderer().isZoomEnabled();
panEnabled = xyChart.getRenderer().isPanEnabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4741,8 +4741,9 @@ public int convertToPixels(int dipCount, boolean horizontal) {
return dipCount * 14;
case Display.DENSITY_HD:
return dipCount * 20;
default:
return dipCount;
}
return dipCount;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions CodenameOne/src/com/codename1/io/ConnectionRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ public void kill() {
killed = true;
//if the connection is in the midle of a reading, stop it to release the
//resources
if (input != null && input instanceof BufferedInputStream) {
if (input instanceof BufferedInputStream) {
((BufferedInputStream) input).stop();
}
NetworkManager.getInstance().kill9(this);
Expand Down Expand Up @@ -2142,13 +2142,13 @@ void updateActivity() {
* Returns the time since the last activity update
*/
int getTimeSinceLastActivity() {
if (input != null && input instanceof BufferedInputStream) {
if (input instanceof BufferedInputStream) {
long t = ((BufferedInputStream) input).getLastActivityTime();
if (t > timeSinceLastUpdate) {
timeSinceLastUpdate = t;
}
}
if (output != null && output instanceof BufferedOutputStream) {
if (output instanceof BufferedOutputStream) {
long t = ((BufferedOutputStream) output).getLastActivityTime();
if (t > timeSinceLastUpdate) {
timeSinceLastUpdate = t;
Expand Down
1 change: 1 addition & 0 deletions CodenameOne/src/com/codename1/io/JSONParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ private static boolean useBoolean(JSONParseCallback callback) {
* @param callback a generic callback to receive the parse events
* @throws IOException if thrown by the stream
*/
@SuppressWarnings("PMD.SwitchStmtsShouldHaveDefault")
public static void parse(Reader i, JSONParseCallback callback) throws IOException {
boolean quoteMode = false;
ReaderClass rc = new ReaderClass();
Expand Down
1 change: 1 addition & 0 deletions CodenameOne/src/com/codename1/io/JSONSanitizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ int getMaximumNestingDepth() {
return this.maximumNestingDepth;
}

@SuppressWarnings("PMD.SwitchStmtsShouldHaveDefault")
void sanitize() {
// Return to consistent state.
bracketDepth = cleaned = 0;
Expand Down
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/io/Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public synchronized void load(InputStream in) throws IOException {
* @throws IOException
* @since 1.6
*/
@SuppressWarnings("fallthrough")
@SuppressWarnings({"fallthrough", "PMD.SwitchStmtsShouldHaveDefault"})
public synchronized void load(Reader in) throws IOException {
if (in == null) {
throw new NullPointerException("in == null");
Expand Down
1 change: 1 addition & 0 deletions CodenameOne/src/com/codename1/io/gzip/InfBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ void reset() {
}
}

@SuppressWarnings("PMD.SwitchStmtsShouldHaveDefault")
int proc(int r) {
int t; // temporary storage
int b; // bit buffer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ private Object evaluateInternal(Object element, int index) {
return evaluateLeftLessRightInternal(element, lvalue, rvalue);
case '%':
return evaluateLeftContainsRightInternal(element, lvalue, rvalue);
default:
return null;
}
return null;
}

/**
Expand Down
1 change: 1 addition & 0 deletions CodenameOne/src/com/codename1/processing/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ private List internalGetAsArray(final String path)
* @return
* @throws IllegalArgumentException
*/
@SuppressWarnings("PMD.SwitchStmtsShouldHaveDefault")
private StructuredContent apply(final StructuredContent start,
final List tokens, final int firstToken)
throws IllegalArgumentException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ static boolean isSubscript(final char ch) {
case Result.ARRAY_START:
case Result.ARRAY_END:
return true;
default:
return false;
}
return false;
}

static boolean isSeparator(final char ch) {
Expand Down
3 changes: 2 additions & 1 deletion CodenameOne/src/com/codename1/properties/UiBinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ private static ObjectConverter pickerTypeToConverter(int type) {
return new IntegerConverter();
case Display.PICKER_TYPE_STRINGS:
return new StringConverter();
default:
throw new IllegalArgumentException("Unsupported picker type: " + type);
}
throw new IllegalArgumentException("Unsupported picker type: " + type);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/ui/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -8183,7 +8183,7 @@ public void paint(Graphics g, Rectangle rect) {
y = rect.getY();
int iW = img.getWidth();
int iH = img.getHeight();
switch (s.getBackgroundType()) {
switch (s.getBackgroundType()) { // NOPMD SwitchStmtsShouldHaveDefault
case Style.BACKGROUND_IMAGE_SCALED:
if (Display.impl.isScaledImageDrawingSupported()) {
g.drawImage(img, x, y, width, height);
Expand Down
6 changes: 5 additions & 1 deletion CodenameOne/src/com/codename1/ui/Display.java
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,8 @@ public boolean isInTransition() {
return false;
}

// Seems to be a false positive on this rule
@SuppressWarnings("PMD.SimplifyConditional")
private void paintTransitionAnimation() {
Animation ani = animationQueue.get(0);
if (!ani.animate()) {
Expand Down Expand Up @@ -1557,6 +1559,8 @@ void setCurrent(final Form newForm, boolean reverse) {
case SHOW_DURING_EDIT_SET_AS_NEXT:
impl.setCurrentForm(newForm);
return;
default:
break;
}
}

Expand Down Expand Up @@ -2543,7 +2547,7 @@ private Form getCurrentUpcomingForm(boolean includeMenus) {
*/
public Form getCurrent() {
Form current = impl.getCurrentForm();
if (current != null && current instanceof Dialog) {
if (current instanceof Dialog) {
if (current.isMenu() || current.isDisposed()) {
Form p = current.getPreviousForm();
if (p != null) {
Expand Down
3 changes: 2 additions & 1 deletion CodenameOne/src/com/codename1/ui/Label.java
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,9 @@ public int getBaselineResizeBehavior() {
return BRB_CONSTANT_DESCENT;
case CENTER:
return BRB_CENTER_OFFSET;
default:
return BRB_OTHER;
}
return BRB_OTHER;
}

@Override
Expand Down
1 change: 1 addition & 0 deletions CodenameOne/src/com/codename1/ui/RunnableWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public void setDone(boolean done) {
}

@Override
@SuppressWarnings("PMD.SwitchStmtsShouldHaveDefault")
public void run() {
if (parentForm != null) {
// set current form uses this portion to make sure all set current operations
Expand Down
12 changes: 6 additions & 6 deletions CodenameOne/src/com/codename1/ui/Sheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,9 @@ private int getHiddenX(Container cnt) {
return cnt.getWidth();
case W:
return -getPreferredW(cnt);
default:
return 0;
}
return 0;
}

/**
Expand All @@ -686,8 +687,9 @@ private int getHiddenY(Container cnt) {
return 0;
case N:
return -getPreferredH(cnt);
default:
return 0;
}
return 0;
}

/**
Expand All @@ -707,11 +709,9 @@ private int getPreferredW(Container cnt) {
case W:
case E:
return Math.min(getPreferredW() + (backButton.getPreferredW() + backButton.getStyle().getHorizontalMargins()) * 2, cnt.getWidth());


default:
return getPreferredW();
}
return getPreferredW();

}

private int getPositionInt() {
Expand Down
15 changes: 4 additions & 11 deletions CodenameOne/src/com/codename1/ui/TextArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -755,17 +755,7 @@ protected boolean isSelectableInteraction() {
}

private boolean isTypedKey(int code) {
if (true) {
return code > 0;
}

return (code >= 48 && code <= 90) // 0-9a-z
||
(code >= 96 && code <= 111) // number pad and arithmetic
||
(code >= 186 && code <= 192) // punctuation
||
(code >= 219 && code <= 222); // brackets & quotes
return code > 0;
}

/**
Expand Down Expand Up @@ -1634,6 +1624,9 @@ public int getAbsoluteAlignment() {
return LEFT;
case LEFT:
return RIGHT;
default:
// unnecessary, but makes the flow clearer and makes PMD happy
return a;
}
}
return a;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ private Motion createMotion(int startOffset, int dest, int speed) {
* {@inheritDoc}
*/
@Override
@SuppressWarnings("PMD.SwitchStmtsShouldHaveDefault")
public boolean animate() {
if (timeline != null) {
return timeline.animate();
Expand Down
1 change: 1 addition & 0 deletions CodenameOne/src/com/codename1/ui/html/CSSBgPainter.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ private Container getScrollableParent(Component parent) {
* {@inheritDoc}
*/
@Override
@SuppressWarnings("PMD.SwitchStmtsShouldHaveDefault")
public void paint(Graphics g, Rectangle rect) {
Style s = parent.getStyle();
int x = rect.getX();
Expand Down
2 changes: 2 additions & 0 deletions CodenameOne/src/com/codename1/ui/html/CSSElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,8 @@ boolean matchAttributeSelections(HTMLElement element) {
return false;
}
break;
default:
return true;
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion CodenameOne/src/com/codename1/ui/html/CSSEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ private void applyStyle(HTMLElement element, CSSElement selector, HTMLComponent
}
for (int iter = 0; iter < element.getUi().size(); iter++) {
Object o = element.getUi().elementAt(iter);
if (o != null && o instanceof Component) {
if (o instanceof Component) {
final Component cmp = (Component) o;
applyStyleToUIElement(cmp, selector, element, htmlC);
}
Expand Down Expand Up @@ -971,6 +971,7 @@ private void setQuotesRecursive(Component cmp, String[] quotes) {
* @param htmlC The HTMLComponent to which this element belongs to
* @param focus true if the style should be applied only to the selected state iof the ui (a result of pseudo-class selector a:focus etc.)
*/
@SuppressWarnings("PMD.SwitchStmtsShouldHaveDefault")
private void applyStyleToUIElement(Component ui, CSSElement selector, HTMLElement element, HTMLComponent htmlC) {
//count++;
int styles = getApplicableStyles(ui, selector); // This is relevant only for non recursive types - otherwise we need to recheck everytime since it depends on the specific UI component class
Expand Down
3 changes: 2 additions & 1 deletion CodenameOne/src/com/codename1/ui/html/HTMLComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -4188,8 +4188,9 @@ private String getListIndexString(int index, int type) {
return getRomanIndexString(index);
case LIST_ROMAN_LOWER:
return getRomanIndexString(index).toLowerCase();
default:
return " "; //In case of "none" - To keep indentation
}
return " "; //In case of "none" - To keep indentation
}

String getLiteral(int index, char baseChar) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ public static int getPlatformDPI(int plaf) {
return 96;
case Display.DENSITY_VERY_LOW:
return 72;
default:
return 96;
}
return 96;
}

/**
Expand Down
13 changes: 8 additions & 5 deletions CodenameOne/src/com/codename1/ui/layouts/mig/UnitValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ public float getPixelsExact(float refValue, ContainerWrapper parent, ComponentWr
case LABEL_ALIGN:
return PlatformDefaults.getLabelAlignPercentage() * refValue;

case IDENTITY:
default:
throw new IllegalArgumentException("Unknown/illegal unit: " + unit + ", unitStr: " + unitStr);
}
throw new IllegalArgumentException("Unknown/illegal unit: " + unit + ", unitStr: " + unitStr);
}

if (subUnits != null && subUnits.length == 2) {
Expand All @@ -456,10 +456,12 @@ public float getPixelsExact(float refValue, ContainerWrapper parent, ComponentWr
return r1 > r2 ? r1 : r2;
case MID:
return (r1 + r2) * 0.5f;
default:
throw new IllegalArgumentException("Subunit: Unknown Oper: " + oper);
}
}

throw new IllegalArgumentException("Internal: Unknown Oper: " + oper);
throw new IllegalArgumentException("Internal: invalid subunits: " + Arrays.toString(subUnits));
}

private float lookup(float refValue, ContainerWrapper parent, ComponentWrapper comp) {
Expand Down Expand Up @@ -568,9 +570,10 @@ boolean isAbsolute() {
case LABEL_ALIGN:
return false;

case IDENTITY:
//case IDENTITY:
default:
throw new IllegalArgumentException("Unknown/illegal unit: " + unit + ", unitStr: " + unitStr);
}
throw new IllegalArgumentException("Unknown/illegal unit: " + unit + ", unitStr: " + unitStr);
}

boolean isAbsoluteDeep() {
Expand Down
9 changes: 4 additions & 5 deletions CodenameOne/src/com/codename1/ui/plaf/Border.java
Original file line number Diff line number Diff line change
Expand Up @@ -1255,8 +1255,9 @@ public Border createPressedVersion() {
b.themeColors = themeColors;
return b;
}
default:
return this;
}
return this;
}

/**
Expand Down Expand Up @@ -1291,6 +1292,7 @@ public void paintBorderBackground(Graphics g, Component c) {
}
}

@SuppressWarnings("PMD.SwitchStmtsShouldHaveDefault")
private void paintBorderBackground(Graphics g, final int xParameter, final int yParameter,
final int widthParameter, final int heightParameter, Component c) {
int originalColor = g.getColor();
Expand Down Expand Up @@ -1859,10 +1861,7 @@ void paint(Graphics g, int x, int y, int width, int height, Component c) {
//g.popClip();
}
break;
case TYPE_IMAGE:
case TYPE_IMAGE_SCALED:
case TYPE_IMAGE_HORIZONTAL:
case TYPE_IMAGE_VERTICAL:
default:
break;
}
g.setColor(originalColor);
Expand Down
Loading
Loading