diff --git a/.all-contributorsrc b/.all-contributorsrc
index 717e21a7d5..66cd053fa8 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -6621,6 +6621,15 @@
"contributions": [
"code"
]
+ },
+ {
+ "login": "VoidxHoshi",
+ "name": "LaLucid",
+ "avatar_url": "https://avatars.githubusercontent.com/u/55886143?v=4",
+ "profile": "https://github.com/VoidxHoshi",
+ "contributions": [
+ "code"
+ ]
}
],
"contributorsPerLine": 7,
diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md
index c0c5daead0..b252c1d257 100644
--- a/docs/pages/pmd/projectdocs/credits.md
+++ b/docs/pages/pmd/projectdocs/credits.md
@@ -395,552 +395,553 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
 Koen Van Looveren π |
 Kris Scheibe π» π |
 Kunal Thanki π |
+  LaLucid π» |
 Larry Diamond π» π |
 Lars Knickrehm π |
 Leo Gutierrez π |
-  LiGaOg π» |
+  LiGaOg π» |
 Lintsi π |
 Linus Fernandes π |
 Lixon Lookose π |
 Logesh π |
 Lorenzo Gabriele π |
 LoΓ―c Ledoyen π |
-  Lucas Silva π |
+  Lucas Silva π |
 Lucas Soncini π» π |
 Lukasz Slonina π |
 Lukebray π |
 Lyor Goldstein π |
 MCMicS π |
 Macarse π |
-  Machine account for PMD π» |
+  Machine account for PMD π» |
 Maciek Siemczyk π |
 Maikel Steneker π» π |
 Maksim Moiseikin π |
 Manfred Koch π |
 Manuel Moya Ferrer π» π |
 Manuel Ryan π |
-  Marat Vyshegorodtsev π |
+  Marat Vyshegorodtsev π |
 Marcel HΓ€rle π |
 Marcello Fialho π |
 Marcin Rataj π |
 Mark Adamcin π |
 Mark Hall π» π |
 Mark Kolich π |
-  Mark Pritchard π |
+  Mark Pritchard π |
 Markus Rathgeb π |
 Marquis Wang π |
 Martin Feldsztejn π |
 Martin Lehmann π |
 Martin Spamer π |
 Martin TarjΓ‘nyi π |
-  MatFl π |
+  MatFl π |
 Mateusz Stefanski π |
 Mathieu Gouin π |
 MatiasComercio π» π |
 Matt Benson π |
 Matt De Poorter π |
 Matt Harrah π |
-  Matt Nelson π |
+  Matt Nelson π |
 Matthew Amos π |
 Matthew Duggan π |
 Matthew Hall π |
 MatΓas Fraga π» π |
 Maxime Robert π» π |
 MetaBF π |
-  Michael π |
+  Michael π |
 Michael Bell π |
 Michael Bernstein π |
 Michael Clay π |
 Michael Dombrowski π |
 Michael Hausegger π |
 Michael Hoefer π |
-  Michael MΓΆbius π |
+  Michael MΓΆbius π |
 Michael N. Lipp π |
 Michael Pellegrini π |
 Michal Kordas π |
 MichaΕ Borek π |
 MichaΕ KuliΕski π |
 Miguel NΓΊΓ±ez DΓaz-Montes π |
-  Mihai Ionut π |
+  Mihai Ionut π |
 Mirek Hankus π |
 Mladjan Gadzic π |
 MrAngry52 π |
 Muminur Choudhury π |
 Mykhailo Palahuta π» π |
 Nagendra Kumar Singh π |
-  Nahuel Barrios π |
+  Nahuel Barrios π |
 Nathan Braun π |
 Nathan Reynolds π |
 Nathan Reynolds π |
 NathanaΓ«l π |
 Nazdravi π |
 Neha-Dhonde π |
-  Nicholas Doyle π |
+  Nicholas Doyle π |
 Nick Butcher π |
 Nico Gallinal π |
 Nicola Dal Maso π |
 Nicolas Filotto π» |
 Nikita Chursin π |
 Niklas Baudy π |
-  Nikolas Havrikov π |
+  Nikolas Havrikov π |
 Nilesh Virkar π |
 Nimit Patel π |
 Niranjan Harpale π |
 Noah Sussman π |
 Noah0120 π |
 Noam Tamim π |
-  Noel Grandin π |
+  Noel Grandin π |
 Olaf Haalstra π |
 Oleg Pavlenko π |
 Oleksii Dykov π» |
 Oliver Eikemeier π |
 Olivier Parent π» π |
 Ollie Abbey π» π |
-  OverDrone π |
+  OverDrone π |
 Ozan Gulle π» π |
 PUNEET JAIN π |
 Parbati Bose π |
 Paul Berg π |
 Pavel Bludov π |
 Pavel MiΔka π |
-  Pedro Nuno Santos π |
+  Pedro Nuno Santos π |
 Pedro Rijo π |
 Pelisse Romain π» π π |
 Pete Davids π |
 Peter Bruin π |
 Peter Chittum π» π |
 Peter Cudmore π |
-  Peter Kasson π |
+  Peter Kasson π |
 Peter Kofler π |
 Pham Hai Trung π |
 Philip Graf π» π |
 Philip Hachey π |
 Philippe Ozil π |
 Phinehas Artemix π |
-  Phokham Nonava π |
+  Phokham Nonava π |
 Piotr SzymaΕski π |
 Piotrek Ε»ygieΕo π» π |
 Pranay Jaiswal π |
 Prasad Kamath π |
 Prasanna π |
 Presh-AR π |
-  Puneet1726 π |
+  Puneet1726 π |
 Rafael CortΓͺs π |
 RaheemShaik999 π |
 RajeshR π» π |
 Ramachandra Mohan π |
 Raquel Pau π |
 Ravikiran Janardhana π |
-  Reda Benhemmouche π |
+  Reda Benhemmouche π |
 Renato Oliveira π» π |
 Rich DiCroce π |
 Riot R1cket π |
 Rishabh Jain π |
 RishabhDeep Singh π |
 Robbie Martinus π» π |
-  Robert Henry π |
+  Robert Henry π |
 Robert Painsi π |
 Robert Russell π |
 Robert SΓΆsemann π» π π’ π |
 Robert Whitebit π |
 Robin Richtsfeld π |
 Robin Stocker π» π |
-  Robin Wils π |
+  Robin Wils π |
 RochusOest π |
 Rodolfo Noviski π |
 Rodrigo Casara π |
 Rodrigo Fernandes π |
 Roman Salvador π» π |
 Ronald Blaschke π |
-  RΓ³bert Papp π |
+  RΓ³bert Papp π |
 Saikat Sengupta π |
 Saksham Handu π |
 Saladoc π |
 Salesforce Bob Lightning π |
 Sam Carlberg π |
 Satoshi Kubo π |
-  Scott Kennedy π |
+  Scott Kennedy π |
 Scott Wells π π» |
 Scrsloota π» |
 Sebastian BΓΆgl π |
 Sebastian Schuberth π |
 Sebastian Schwarz π |
 Sergey Gorbaty π |
-  Sergey Kozlov π |
+  Sergey Kozlov π |
 Sergey Yanzin π» π |
 Seth Wilcox π» |
 Shubham π» π |
 Simon Xiao π |
 Srinivasan Venkatachalam π |
 Stanislav Gromov π |
-  Stanislav Myachenkov π» |
+  Stanislav Myachenkov π» |
 Stefan Birkner π |
 Stefan Bohn π |
 Stefan Endrullis π |
 Stefan KlΓΆss-Schuster π |
 Stefan Wolf π |
 Stephan H. Wissel π |
-  Stephen π |
+  Stephen π |
 Stephen Friedrich π |
 Steve Babula π» |
 Stexxe π |
 Stian LΓ₯gstad π |
 StuartClayton5 π |
 Supun Arunoda π |
-  Suren Abrahamyan π |
+  Suren Abrahamyan π |
 SwatiBGupta1110 π |
 SyedThoufich π |
 Szymon Sasin π |
 T-chuangxin π |
 TERAI Atsuhiro π |
 TIOBE Software π» π |
-  Taylor Smock π |
+  Taylor Smock π |
 Techeira DamiΓ‘n π» π |
 Ted Husted π |
 TehBakker π |
 The Gitter Badger π |
 Theodoor π |
 Thiago Henrique HΓΌpner π |
-  Thibault Meyer π |
+  Thibault Meyer π |
 Thomas GΓΌttler π |
 Thomas Jones-Low π |
 Thomas Smith π» π |
 ThrawnCA π |
 Thunderforge π» π |
 Tim van der Lippe π |
-  Tobias Weimer π» π |
+  Tobias Weimer π» π |
 Tom Daly π |
 Tomer Figenblat π |
 Tomi De Lucca π» π |
 Torsten Kleiber π |
 TrackerSB π |
 Ullrich Hafner π |
-  Utku Cuhadaroglu π» π |
+  Utku Cuhadaroglu π» π |
 Valentin Brandl π |
 Valeria π |
 Vasily Anisimov π |
 Vickenty Fesunov π |
 Victor NoΓ«l π |
 Vincent Galloy π» |
-  Vincent HUYNH π |
+  Vincent HUYNH π |
 Vincent Maurin π |
 Vincent Privat π |
 Vishhwas π |
 Vitaly π |
 Vitaly Polonetsky π |
 Vojtech Polivka π |
-  Vsevolod Zholobov π |
+  Vsevolod Zholobov π |
 Vyom Yadav π» |
 Wang Shidong π |
 Waqas Ahmed π |
 Wayne J. Earl π |
 Wchenghui π |
 Will Winder π |
-  William Brockhus π» π |
+  William Brockhus π» π |
 Wilson Kurniawan π |
 Wim Deblauwe π |
 Woongsik Choi π |
 XenoAmess π» π |
 Yang π» |
 YaroslavTER π |
-  Young Chan π» π |
+  Young Chan π» π |
 YuJin Kim π |
 Yuri Dolzhenko π |
 Yurii Dubinka π |
 Zoltan Farkas π |
 Zustin π |
 aaronhurst-google π |
-  alexmodis π |
+  alexmodis π |
 andreoss π |
 andrey81inmd π» π |
 anicoara π |
 arunprasathav π |
 asiercamara π |
 astillich-igniti π» |
-  avesolovksyy π |
+  avesolovksyy π |
 avishvat π |
 avivmu π |
 axelbarfod1 π |
 b-3-n π |
 balbhadra9 π |
 base23de π |
-  bergander π |
+  bergander π |
 berkam π» π |
 breizh31 π |
 caesarkim π |
 carolyujing π |
 cesares-basilico π |
 chrite π |
-  cobratbq π |
+  cobratbq π |
 coladict π |
 cosmoJFH π |
 cristalp π |
 crunsk π |
 cwholmes π |
 cyberjj999 π |
-  cyw3 π |
+  cyw3 π |
 d1ss0nanz π |
 danbrycefairsailcom π |
 dariansanity π |
 darrenmiliband π |
 davidburstrom π |
 dbirkman-paloalto π |
-  deepak-patra π |
+  deepak-patra π |
 dependabot[bot] π» π |
 dinesh150 π |
 diziaq π |
 dreaminpast123 π |
 duanyanan π |
 dutt-sanjay π |
-  dylanleung π |
+  dylanleung π |
 dzeigler π |
 ekkirala π |
 emersonmoura π |
 fairy π |
 filiprafalowicz π» |
 foxmason π |
-  frankegabor π |
+  frankegabor π |
 frankl π |
 freafrea π |
 fsapatin π |
 gracia19 π |
 guo fei π |
 gurmsc5 π |
-  gwilymatgearset π» π |
+  gwilymatgearset π» π |
 haigsn π |
 hemanshu070 π |
 henrik242 π |
 hongpuwu π |
 hvbtup π» π |
 igniti GmbH π |
-  ilovezfs π |
+  ilovezfs π |
 itaigilo π |
 jakivey32 π |
 jbennett2091 π |
 jcamerin π |
 jkeener1 π |
 jmetertea π |
-  johnra2 π» |
+  johnra2 π» |
 josemanuelrolon π» π |
 kabroxiko π» π |
 karwer π |
 kaulonline π |
 kdaemonv π |
 kenji21 π» π |
-  kfranic π |
+  kfranic π |
 khalidkh π |
 krzyk π |
 lasselindqvist π |
 lihuaib π |
 lonelyma1021 π |
 lpeddy π |
-  lujiefsi π» |
+  lujiefsi π» |
 lyriccoder π |
 marcelmore π |
 matchbox π |
 matthiaskraaz π |
 meandonlyme π |
 mikesive π |
-  milossesic π |
+  milossesic π |
 mriddell95 π |
 mrlzh π |
 msloan π |
 mucharlaravalika π |
 mvenneman π |
 nareshl119 π |
-  nicolas-harraudeau-sonarsource π |
+  nicolas-harraudeau-sonarsource π |
 noerremark π |
 novsirion π |
 oggboy π |
 oinume π |
 orimarko π» π |
 pallavi agarwal π |
-  parksungrin π |
+  parksungrin π |
 patpatpat123 π |
 patriksevallius π |
 pbrajesh1 π |
 phoenix384 π |
 piotrszymanski-sc π» |
 plan3d π |
-  poojasix π |
+  poojasix π |
 prabhushrikant π |
 pujitha8783 π |
 r-r-a-j π |
 raghujayjunk π |
 rajeshveera π |
 rajeswarreddy88 π |
-  recdevs π |
+  recdevs π |
 reudismam π» π |
 rijkt π |
 rillig-tk π |
 rmohan20 π» π |
 rxmicro π |
 ryan-gustafson π» π |
-  sabi0 π |
+  sabi0 π |
 scais π |
 sebbASF π |
 sergeygorbaty π» |
 shilko2013 π |
 simeonKondr π |
 snajberk π |
-  sniperrifle2004 π |
+  sniperrifle2004 π |
 snuyanzin π π» |
 sratz π |
 stonio π |
 sturton π» π |
 sudharmohan π |
 suruchidawar π |
-  svenfinitiv π |
+  svenfinitiv π |
 tashiscool π |
 test-git-hook π |
 testation21 π» π |
 thanosa π |
 tiandiyixian π |
 tobwoerk π |
-  tprouvot π |
+  tprouvot π |
 trentchilders π |
 triandicAnt π |
 trishul14 π |
 tsui π |
 winhkey π |
 witherspore π |
-  wjljack π |
+  wjljack π |
 wuchiuwong π |
 xingsong π |
 xioayuge π |
 xnYi9wRezm π» π |
 xuanuy π |
 xyf0921 π |
-  yalechen-cyw3 π |
+  yalechen-cyw3 π |
 yasuharu-sato π |
 zenglian π |
 zgrzyt93 π» π |
 zh3ng π |
 zt_soft π |
 ztt79 π |
-  zzzzfeng π |
+  zzzzfeng π |
 ΓrpΓ‘d MagosΓ‘nyi π |
 δ»»θ΄΅ζ° π |
diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md
index 37492cb23a..400d774f08 100644
--- a/docs/pages/release_notes.md
+++ b/docs/pages/release_notes.md
@@ -32,6 +32,7 @@ This is a {{ site.pmd.release_type }} release.
* [#2505](https://github.com/pmd/pmd/issues/2505): \[doc] Improve side bar to show release date
* java
* [#3068](https://github.com/pmd/pmd/issues/3068): \[java] Some tests should not depend on real rules
+ * [#3603](https://github.com/pmd/pmd/issues/3603): \[java] SimplifiedTernary: no violation for 'condition ? true : false' case
* [#3889](https://github.com/pmd/pmd/pull/3889): \[java] Catch LinkageError in UselessOverridingMethodRule
* [#3910](https://github.com/pmd/pmd/pull/3910): \[java] UnusedPrivateField - Allow the ignored fieldnames to be configurable
* java-bestpractices
@@ -60,6 +61,7 @@ This is a {{ site.pmd.release_type }} release.
* [#3910](https://github.com/pmd/pmd/pull/3910): \[java] UnusedPrivateField - Allow the ignored fieldnames to be configurable - [@laoseth](https://github.com/laoseth)
* [#3928](https://github.com/pmd/pmd/pull/3928): \[plsql] Fix plsql parsing error in parenthesis groups - [@LiGaOg](https://github.com/LiGaOg)
* [#3935](https://github.com/pmd/pmd/pull/3935): \[plsql] Fix parser exception in EXECUTE IMMEDIATE BULK COLLECT #3687 - [@Scrsloota](https://github.com/Scrsloota)
+* [#3938](https://github.com/pmd/pmd/pull/3938): \[java] Modify SimplifiedTernary to meet the missing case #3603 - [@VoidxHoshi](https://github.com/VoidxHoshi)
{% endtocmaker %}
diff --git a/pmd-java/src/main/resources/category/java/design.xml b/pmd-java/src/main/resources/category/java/design.xml
index f071a261f9..b285179dba 100644
--- a/pmd-java/src/main/resources/category/java/design.xml
+++ b/pmd-java/src/main/resources/category/java/design.xml
@@ -1291,12 +1291,11 @@ public void foo() throws Exception {
Look for ternary operators with the form `condition ? literalBoolean : foo`
or `condition ? foo : literalBoolean`.
-These expressions can be simplified respectively to
-`condition || foo` when the literalBoolean is true
-`!condition && foo` when the literalBoolean is false
-or
-`!condition || foo` when the literalBoolean is true
-`condition && foo` when the literalBoolean is false
+These expressions can be simplified as follows:
+* `condition ? true : expr` simplifies to `condition || expr`
+* `condition ? false : expr` simplifies to `!condition && expr`
+* `condition ? expr : true` simplifies to `!condition || expr`
+* `condition ? expr : false` simplifies to `condition && expr`
]]>
3
@@ -1305,9 +1304,9 @@ or
@@ -1330,6 +1329,10 @@ public class Foo {
public void test4() {
final boolean otherValue = condition ? something() : false; // can be as simple as condition && something();
}
+
+ public boolean test5() {
+ return condition ? true : false; // can be as simple as return condition;
+ }
}
]]>
diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/SimplifiedTernary.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/SimplifiedTernary.xml
index 2002135780..1a01776aeb 100644
--- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/SimplifiedTernary.xml
+++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/SimplifiedTernary.xml
@@ -53,12 +53,12 @@ public class Foo {
- condition ? true : false
- 0
+ #3603 condition ? true : false
+ 1