mirror of
https://github.com/Graylog2/graylog2-server.git
synced 2026-03-13 09:32:21 +08:00
* Replace WithBeanGetterTest with AutoValueValidatorTest We want to ensure that auto-value adds the validation annotations to the generated class fields. * Remove all WithBeanGetter annotation usages - Fix classes where the constructor became private because of the builder usage - Fix wrong "$AutoValue" references * Remove auto-value-javabean dependency * Restore InputCreateRequest#create method * Revert some JsonSeserialize conversions The changes introduced a breaking change in InputCreateRequest, so we play safe for now. * Remove JsonDeserialize from ShardRouting * Convert CreateEntityRequest to a POJO to fix validation issues * Check that CreateEntityRequest#title is not null * Fix botched merge * Explicitly set JsonProperty names to fix parsing issue * Remove unused files * Use explicit values for JsonProperty annotations Removing the WithBeanGetter annotation resulted in some de/serialization errors. We prevent those by using explicit annotation values. * Fix wrong property name * Add PMD rule to check for missing values in JsonProperty annotations * Remove newly introduced WithBeanGetter usages * Add missing license header * Fix "$AutoValue_*" usage
55 lines
2.3 KiB
XML
55 lines
2.3 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<ruleset name="Custom Rules"
|
|
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>Custom Graylog-specific rules</description>
|
|
|
|
<!-- When used in a catch clause, the de.thetaphi:forbiddenapis plugin won't catch usages of the forbidden class.
|
|
Therefore, we have this additional PMD rule to prevent usages. -->
|
|
<rule name="CatchingMongoDBDuplicateKeyException"
|
|
language="java"
|
|
message="Catching a com.mongodb.DuplicateKeyException is prohibited because it will not cover all duplicate key errors. Use org.graylog2.database.utils.MongoUtil#isDuplicateKeyError(MongoException) instead."
|
|
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" >
|
|
<description>
|
|
Prohibit usage of com.mongodb.DuplicateKeyException
|
|
</description>
|
|
<priority>1</priority>
|
|
<properties>
|
|
<property name="xpath">
|
|
<value>
|
|
<![CDATA[
|
|
//CatchParameter/ClassType[pmd-java:typeIs('com.mongodb.DuplicateKeyException')]
|
|
]]>
|
|
</value>
|
|
</property>
|
|
</properties>
|
|
</rule>
|
|
|
|
<rule name="NoJsonPropertyWithoutValueInAutoValueClasses"
|
|
language="java"
|
|
message="Do not use @JsonProperty without an explicit value in @AutoValue classes."
|
|
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
|
|
<description>
|
|
Prohibits usage of @JsonProperty annotations without an explicit value in @AutoValue classes.
|
|
</description>
|
|
<priority>3</priority>
|
|
<properties>
|
|
<property name="xpath">
|
|
<value>
|
|
<![CDATA[
|
|
//ClassDeclaration[pmd-java:hasAnnotation("com.google.auto.value.AutoValue")]//Annotation[
|
|
@SimpleName='JsonProperty' and (
|
|
not(.//MemberValuePair[@Image='value']) or .//MemberValuePair[@Image='value']/StringLiteral[@Image='""']
|
|
)
|
|
]
|
|
]]>
|
|
</value>
|
|
</property>
|
|
</properties>
|
|
</rule>
|
|
|
|
</ruleset>
|