Ok, so, first things first.
I’d suggest you check out the documentation on writing a ruleset:
https://docs.pmd-code.org/latest/pmd_userdocs_making_rulesets.html#referencing-a-single-rule
To reference existing rulesets, it suffices to do just:
<rule ref="category/apex/design.xml/ExcessiveClassLength" />
You don’t need to include the message nor any property unless you want to
*override* the default values for any of these. In your example, you are
just copying the defaults, so none of that is needed. Even if you were
overriding a value, you just need to include the one you want to override,
not all of them.
The rule’s doc shows the difference between just referencing / customizing
it (and neither includes the message attribute).
https://docs.pmd-code.org/latest/pmd_rules_apex_design.html#excessiveclasslength
As for the cc_* attributes in general, *just remove them*. They referenced
CodeClimate <https://codeclimate.com/>. They do not affect the rule itself,
but how it renders data *iff* using the code climate renderer. As this is a
renderer-specific thing, it didn’t make sense to have it as part of each
rule, and hence, was deprecated and eventually removed. If you are not
using Code Climate, you won’t see a difference. If you are, you will simply
stop having category / remediation points info.
Regards
On Mon, Nov 11, 2024 at 1:55 AM Abhinav kumar <abh...@gm...>
wrote:
> Hello Juan,
>
> What will be the impact when we remove these properties " cc_categories
> , cc_remediation_points_multiplier, cc_block_highlighting " in our PMD
> analysis?
> Is there any alternative to these properties which we can include in our
> ruleset file.
> Please find the rule snippet below for your reference. This is how we have
> defined our custom ruleset.
> <rule ref="category/apex/design.xml/ExcessiveClassLength" message=
> "Avoid really long classes (lines of code)">
> <priority>3</priority>
> <properties>
> <property name="minimum" value="1000" />
> <!-- relevant for Code Climate output only -->
> <property name="cc_categories" value="Complexity" />
> <property name="cc_remediation_points_multiplier" value="150" />
> <property name="cc_block_highlighting" value="false" />
> </properties>
> </rule>
>
> So, how do we rewrite this rule as we will need to remove all the 3
> properties mentioned in the snippet. So how are we going to rewrite the
> rule and also any other property which we need to replace in place of these
> properties?.
>
>
> *NOTE:- These are the properties we are using for all our rulesets, you
> can go through the custom rule set file once which is attached with this
> email, so could you please guide as to how we are rewriting this without
> these properties.*
> Regards,
> Abhinav
>
> On Sun, Nov 10, 2024 at 10:06 AM Juan Martín Sotuyo Dodero <
> jua...@gm...> wrote:
>
>> Yes, simply remove them
>>
>> On Sun, Nov 10, 2024, 1:19 AM Abhinav kumar <abh...@gm...>
>> wrote:
>>
>>> Hello Juan,
>>>
>>> Thank you so much for the response, so what should be the next step?
>>> In Place of these properties " cc_categories,
>>> cc_remediation_points_multiplier, cc_block_highlighting " what should
>>> be used because these are all custom defined rule sets we are using in our
>>> project.
>>>
>>> Should we remove these properties from our file, will that work?
>>>
>>> Awaiting your response.
>>>
>>> Regards,
>>> Abhinav
>>>
>>> On Thu, Nov 7, 2024 at 6:59 PM Juan Martín Sotuyo Dodero <
>>> jua...@gm...> wrote:
>>>
>>>> Abhinav,
>>>>
>>>> PMD 7 is a major release, and as such, introduces breaking changes.
>>>> As per our own policy, we never introduce a breaking change unless the
>>>> relevant feature has already been deprecated in the previous release, and
>>>> ensuring appropriate warnings are emitted with it’s usage, even if still
>>>> supported, with the intention of giving people time to accommodate and
>>>> prepare. Aditionally, with any release, the release notes
>>>> <https://docs.pmd-code.org/latest/pmd_release_notes_pmd7.html>
>>>> comprehensively cover these changes.
>>>>
>>>> As per the error’s self description
>>>>
>>>> 2024-11-04T07:40:49.3666791Z 11| <property name="cc_categories" value="Complexity" />
>>>> 2024-11-04T07:40:49.3667364Z ^^^^^^^^^ Cannot set non-existent property 'cc_categories' on rule ExcessiveClassLength
>>>>
>>>> In this particular case, this is the relevant piece
>>>> <https://docs.pmd-code.org/latest/pmd_release_notes_pmd7.html#changed-rules:~:text=Apex%20General%20changes>
>>>> :
>>>>
>>>> *Apex General changes*
>>>>
>>>> - The properties cc_categories, cc_remediation_points_multiplier,
>>>> cc_block_highlighting have been removed from all rules. These
>>>> properties have been deprecated since PMD 6.13.0. See issue #1648
>>>> <https://github.com/pmd/pmd/issues/1648> for more details.
>>>>
>>>> Hope that helps. Checking the logs for deprecation warnings can
>>>> hopefully help you stay prepared for major changes without affecting your
>>>> workflows.
>>>>
>>>> Regards
>>>>
>>>> On Thu, Nov 7, 2024 at 6:24 AM Abhinav kumar <abh...@gm...>
>>>> wrote:
>>>>
>>>>> Hello Team,
>>>>>
>>>>> I am using sfdx-scanner for my project and custom PMD rule set for the
>>>>> static code analysis.
>>>>> When I upgraded the scanner to 4.0.0, PMD was upgraded to 7.0.0 but
>>>>> then I started getting errors in my pipeline. The same rule set is working
>>>>> fine with the sfdx-scanner 3.25 version. I have attached the error log file.
>>>>>
>>>>> Also, I am attaching the custom ruleset file for your reference.
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Pmd-devel mailing list
>>>>> Pmd...@li...
>>>>> https://lists.sourceforge.net/lists/listinfo/pmd-devel
>>>>>
>>>>
|