You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This should reject Optional usage even if it is not imported since users may use method chaining. I think this might be able to be achieved using PMD with a configuration of something like this:
<?xml version="1.0"?>
<rulesetname="Spring Security"xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>
Rules which enforce generally accepted best practices.
</description>
<rulename="AvoidOptional"language="java"since="3.4"message="Please do not use Optional to avoid unnecessary Garbage Collection."class="net.sourceforge.pmd.lang.rule.XPathRule"externalInfoUrl="https://github.com/spring-projects/spring-security/issues/7155">
<description>
Please do not use Optional to avoid unnecessary Garbage Collection.
</description>
<priority>3</priority>
<properties>
<propertyname="version"value="2.0"/>
<propertyname="xpath">
<value>//Type/ReferenceType/ClassOrInterfaceType[@Image='Optional']</value>
</property>
</properties>
<example>
<![CDATA[public class Foo { void bar() { Optional h = zoop.findOne(); }}]]>
</example>
</rule>
</ruleset>
This should reject Optional usage even if it is not imported since users may use method chaining. I think this might be able to be achieved using PMD with a configuration of something like this:
See gh-7155
The text was updated successfully, but these errors were encountered: