GeezerVison is showing github.com — Merge branch 'main' into unnecessaryboxing-overload-fn · pmd/pmd@1b84182
File treeExpand file treeCollapse file tree Open diff view settings pmd/projectdocs/committers
main/java/net/sourceforge/pmd/lang/java/ast java/net/sourceforge/pmd/lang/java/ast kotlin/net/sourceforge/pmd/lang/java
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .ci/files/Gemfile.lock +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 15 | 15 | logger (1.7.0) | 16 | 16 | logger-colors (1.1.0) | 17 | 17 | logger | 18 | | - nokogiri (1.19.4-x86_64-linux-gnu) | | 18 | + nokogiri (1.19.5-x86_64-linux-gnu) | 19 | 19 | racc (~> 1.4) | 20 | 20 | ostruct (0.6.3) | 21 | 21 | pmdtester (1.7.0) | |
Collapse file Copy file name to clipboardExpand all lines: docs/Gemfile.lock +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | GEM | 2 | 2 | remote: https://rubygems.org/ | 3 | 3 | specs: | 4 | | - addressable (2.9.0) | | 4 | + addressable (2.9.1) | 5 | 5 | public_suffix (>= 2.0.2, < 8.0) | 6 | 6 | base64 (0.3.0) | 7 | 7 | bigdecimal (4.1.3) | |
Collapse file Copy file name to clipboardExpand all lines: docs/pages/pmd/projectdocs/committers/infrastructure.md +7-9Lines changed: 7 additions & 9 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 | title: Infrastructure | 3 | 3 | permalink: pmd_projectdocs_committers_infrastructure.html | 4 | 4 | | 5 | | -last_updated: February 2025 (7.11.0) | | 5 | +last_updated: November 2026 (7.30.0) | 6 | 6 | --- | 7 | 7 |
| 8 | | -This page describes, which infrastructure and services is used by the pmd project. | | 8 | +This page describes which infrastructure and services are used by the pmd project. | 9 | 9 |
| 10 | 10 | ## GitHub | 11 | 11 |
| 12 | 12 | The main repository is hosted on <https://github.com/pmd>. We own the organization "pmd". | 13 | 13 |
| 14 | 14 | * source code in git repositories | 15 | | -* releases | | 15 | +* releases (<https://github.com/pmd/pmd/releases>, or via feed: <https://github.com/pmd/pmd/releases.atom>) | 16 | 16 | * issue tracker | 17 | 17 | * discussions | 18 | 18 | * pull requests | | 19 | +* commit notification via feeds, e.g. <https://github.com/pmd/pmd/commits/main.atom> | 19 | 20 | * [GitHub Actions for CI](pmd_devdocs_github_actions_workflows.html) | 20 | 21 |
| 21 | | -Also the [main landing page](pmd_projectdocs_committers_main_landing_page.html) (<https://pmd.github.io>) | | 22 | +The [main landing page](pmd_projectdocs_committers_main_landing_page.html) (<https://pmd.github.io>) | 22 | 23 | is hosted using GitHub pages. | 23 | 24 |
| 24 | 25 | ## SourceForge | @@ -29,12 +30,9 @@ Nowadays, it is used for: | 29 | 30 |
| 30 | 31 | * hosting an archive of binaries: <https://sourceforge.net/projects/pmd/files/> | 31 | 32 | * hosting an archive of documentation: <https://pmd.sourceforge.io/archive.html> | 32 | | -* mailing lists: | 33 | | - | 34 | | - | 35 | | -* discussion forum | | 33 | + | 36 | 34 |
| 37 | | -It also contains the old issue tracker. | | 35 | +It also contains the old issue tracker and the old discussion forum. | 38 | 36 |
| 39 | 37 | ## Domain, mail and homepage | 40 | 38 |
| |
Collapse file Copy file name to clipboardExpand all lines: docs/pages/release_notes.md +1Lines changed: 1 addition & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -52,6 +52,7 @@ This is a {{ site.pmd.release_type }} release. | 52 | 52 | * java | 53 | 53 | * [#7144](https://github.com/pmd/pmd/issues/7144): \[java] Lambda block body that cannot complete normally is not treated as value-compatible | 54 | 54 | * [#7240](https://github.com/pmd/pmd/issues/7240): \[java] "Not a Java binary name" when importing a class with non-ASCII (e.g. Japanese) letters in its name; the whole file is skipped | | 55 | + * [#7313](https://github.com/pmd/pmd/issues/7313): \[java] Casts to boolean and boolean equality are not folded as constant expressions | 55 | 56 | * java-bestpractices | 56 | 57 | * [#7116](https://github.com/pmd/pmd/issues/7116): \[java] New rule: ControlFlowInTest | 57 | 58 | * [#7216](https://github.com/pmd/pmd/issues/7216): \[java] GuardLogStatement: False positive on SLF4J parameterised calls whose arguments are wrapped with logstash value(...) | |
Collapse file Copy file name to clipboardExpand all lines: pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ConstantFolder.java +12Lines changed: 12 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 15 | 15 | import net.sourceforge.pmd.lang.java.symbols.JFieldSymbol; | 16 | 16 | import net.sourceforge.pmd.lang.java.symbols.JVariableSymbol; | 17 | 17 | import net.sourceforge.pmd.lang.java.types.JPrimitiveType; | | 18 | +import net.sourceforge.pmd.lang.java.types.JPrimitiveType.PrimitiveTypeKind; | 18 | 19 | import net.sourceforge.pmd.lang.java.types.JTypeMirror; | 19 | 20 | import net.sourceforge.pmd.lang.java.types.Substitution; | 20 | 21 | import net.sourceforge.pmd.lang.java.types.TypeTestUtil; | @@ -188,6 +189,8 @@ private ConstResult coerceVariableValue(JVariableSymbol symbol, ConstResult resu | 188 | 189 | Object res; | 189 | 190 | if (t.isNumeric()) { | 190 | 191 | res = numericCoercion(castValue.getValue(), t); | | 192 | + } else if (t.isPrimitive(PrimitiveTypeKind.BOOLEAN)) { | | 193 | + res = booleanCoercion(castValue.getValue()); | 191 | 194 | } else if (TypeTestUtil.isExactlyA(String.class, node.getCastType())) { | 192 | 195 | res = stringCoercion(castValue.getValue()); | 193 | 196 | } else { | @@ -541,6 +544,8 @@ public strictfp ConstResult visit(ASTInfixExpression node, Void data) { | 541 | 544 | if (isConvertibleToNumber(left) && isConvertibleToNumber(right)) { | 542 | 545 | Pair<Object, Object> promoted = binaryNumericPromotion(left, right); | 543 | 546 | return promoted.getLeft().equals(promoted.getRight()); // fixme Double.NaN | | 547 | + } else if (left instanceof Boolean && right instanceof Boolean) { | | 548 | + return left.equals(right); | 544 | 549 | } else { | 545 | 550 | return null; // not a constant expr on reference types | 546 | 551 | } | @@ -630,6 +635,13 @@ private static Object numericCoercion(Object v, JTypeMirror target) { | 630 | 635 | return null; | 631 | 636 | } | 632 | 637 |
| | 638 | + private static Object booleanCoercion(Object v) { | | 639 | + if (v instanceof Boolean) { | | 640 | + return v; | | 641 | + } | | 642 | + return null; | | 643 | + } | | 644 | + | 633 | 645 | private static Object stringCoercion(Object v) { | 634 | 646 | if (v instanceof String) { | 635 | 647 | return v; | |
Collapse file Copy file name to clipboardExpand all lines: pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/ConstantExpressionsTests.java +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -65,8 +65,10 @@ void testCasts() { | 65 | 65 | isConst("(int) 2f", 2), | 66 | 66 | isConst("(short) 2f", (short) 2f), | 67 | 67 | isConst("(long) 2f", 2L), | | 68 | + isConst("(boolean) true", true), | 68 | 69 |
| 69 | 70 | // those are type errors | | 71 | + notConst("(boolean) 1"), | 70 | 72 | notConst("(Object) 1"), | 71 | 73 | notConst("(String) null"), | 72 | 74 | notConst("(char) null"), | @@ -290,11 +292,15 @@ strictfp void testEquality() { | 290 | 292 | isConst("2 != 2d", false), | 291 | 293 | isConst("'x' != (int) 'x'", false), | 292 | 294 | isConst("'x' == (int) 'x'", true), | | 295 | + isConst("true == true", true), | | 296 | + isConst("false == false", true), | | 297 | + isConst("true != false", true), | 293 | 298 |
| 294 | 299 |
| 295 | 300 | notConst("\"\" == \"\""), | 296 | 301 | notConst("\"\" != \"\""), | 297 | | - notConst("2 != \"\"") | | 302 | + notConst("2 != \"\""), | | 303 | + notConst("true == 1") | 298 | 304 | ); | 299 | 305 | } | 300 | 306 |
| |
Collapse file Copy file name to clipboardExpand all lines: pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/ConstValuesKotlinTest.kt +28Lines changed: 28 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -118,6 +118,34 @@ class ConstValuesKotlinTest : ProcessorTestSpec({ | 118 | 118 | acu.initializerOf("result").constValue shouldBe null | 119 | 119 | } | 120 | 120 |
| | 121 | + parserTest("Comparing or casting boxed Boolean locals is foldable but is not a constant expression") { | | 122 | + val acu = parser.parse( | | 123 | + """ | | 124 | + class Foo { | | 125 | + void test() { | | 126 | + final Boolean boxedTrue = true; | | 127 | + final Boolean boxedFalse = false; | | 128 | + final boolean primTrue = true; | | 129 | + final boolean primFalse = false; | | 130 | + boolean same = boxedTrue == boxedFalse; | | 131 | + boolean unboxed = boxedTrue == true; | | 132 | + boolean cast = (boolean) boxedTrue; | | 133 | + boolean primSame = primTrue == primFalse; | | 134 | + } | | 135 | + } | | 136 | + """.trimIndent() | | 137 | + ) | | 138 | + | | 139 | + acu.initializerOf("same").constFoldingResult.value shouldBe false | | 140 | + acu.initializerOf("same").isCompileTimeConstant shouldBe false | | 141 | + acu.initializerOf("unboxed").constFoldingResult.value shouldBe true | | 142 | + acu.initializerOf("unboxed").isCompileTimeConstant shouldBe false | | 143 | + acu.initializerOf("cast").constFoldingResult.value shouldBe true | | 144 | + acu.initializerOf("cast").isCompileTimeConstant shouldBe false | | 145 | + acu.initializerOf("primSame").constFoldingResult.value shouldBe false | | 146 | + acu.initializerOf("primSame").isCompileTimeConstant shouldBe true | | 147 | + } | | 148 | + | 121 | 149 | parserTest("Local numeric constants use their declared types") { | 122 | 150 | val acu = parser.parse( | 123 | 151 | """ | |
Collapse file Copy file name to clipboardExpand all lines: pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/types/internal/infer/LambdaInferenceTest.kt +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -562,6 +562,7 @@ class Scratch { | 562 | 562 | testBody("{ for (; 1 < 2;) { } }", void = true, value = true) | 563 | 563 | testBody("{ while (forever) { } }", void = true, value = true) | 564 | 564 | testBody("{ while (FOREVER) { } }", void = true, value = true) | | 565 | + testBody("{ while (FOREVER == true) { } }", void = true, value = true) | 565 | 566 | testBody("{ while (b) { } }", void = true) | 566 | 567 | testBody("{ while (true || b) { } }", void = true) | 567 | 568 |
| |
Collapse file Copy file name to clipboardExpand all lines: pom.xml +1-3Lines changed: 1 addition & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 45 | 45 | </mailingList> | 46 | 46 | <mailingList> | 47 | 47 | <name>PMD commits</name> | 48 | | - <subscribe>https://lists.sourceforge.net/lists/listinfo/pmd-commits</subscribe> | 49 | | - <unsubscribe>https://lists.sourceforge.net/lists/listinfo/pmd-commits</unsubscribe> | 50 | | - <archive>https://sourceforge.net/p/pmd/mailman/pmd-commits</archive> | | 48 | + <archive>https://github.com/pmd/pmd/commits/main</archive> | 51 | 49 | </mailingList> | 52 | 50 | </mailingLists> | 53 | 51 | <developers> | |
|