hardisgroupcom / sfdx-hardis

Swiss-army-knife Toolbox for Salesforce. Orchestrates base commands and assist users with interactive wizards to make much more than native sfdx + Allows you to define a complete CI/CD Pipeline and Schedule a daily Metadata backup & monitoring of your orgs
https://sfdx-hardis.cloudity.com
GNU Affero General Public License v3.0
183 stars 32 forks source link

PMD Ruleset Configuration Error and Technical Definition Visibility Loss in Pipeline #643

Open yamioliva opened 1 month ago

yamioliva commented 1 month ago

Hey team, we've run into an issue with the PMD ruleset configuration while using the sfdx-hardis plugin.

So, here's what's happening:

  1. We run the pipeline with the sfdx-hardis plugin.
  2. We hit a PMD ruleset configuration error.
  3. To get around it, we modified the YAML file to skip the problematic section.
  4. But now, we're missing the technical definitions in our pipeline, which we really need.

Expected Behavior:

The PMD ruleset should run without errors, and the technical definitions should be visible in the pipeline.

Actual Behavior:

Screenshots:

Initial Error in PMD Ruleset Configuration: Initial Error in PMD Ruleset Configuration

Configuration Workaround: Configuration Workaround

Missing Technical Definitions in Pipeline: Missing Technical Definitions in Pipeline2

Missing Technical Definitions in Pipeline

PMD Ruleset XML Configuration: PMD Ruleset XML Configuration

Environment:

Additional Context:

We applied the workaround by skipping the error in the YAML file, which fixed the initial problem but caused us to lose the technical definition visibility in the pipeline.

We're looking for help to solve the PMD ruleset configuration error without losing the technical definitions in the pipeline. Has anyone else faced this? Any known fixes?

Thanks for your support!

nvuillam commented 1 month ago

hi @yamioliva :)

I think it's related to the newest version of MegaLinter, that contains sfdx-scanner v4, that contains PMD7 (previous was PMD6)

Some PMD6 rules has been removed, so you can just remove the crashing part (the custom Xpath rule) in your PMD ruleset XML file, and it should be ok :)

Best regards

nvuillam commented 1 month ago

@yamioliva I think I solved the issue on the online default PMD rulesets file :)

Please can yo ucheck again ? :)

yamioliva commented 1 month ago

Hi Nico,

Thanks for the quick response!

Ok! I’ll keep you posted on the outcome.

Best regards, Yamilet

El vie, 12 jul 2024, 14:50, Nicolas Vuillamy @.***> escribió:

@yamioliva https://github.com/yamioliva I think I solved the issue on the online default PMD rulesets file :)

Please can yo ucheck again ? :)

— Reply to this email directly, view it on GitHub https://github.com/hardisgroupcom/sfdx-hardis/issues/643#issuecomment-2225511184, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJDGDT5DW3NL25FBIJ36IYTZL7GI3AVCNFSM6AAAAABKXNJ25KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRVGUYTCMJYGQ . You are receiving this because you were mentioned.Message ID: @.***>

yamioliva commented 1 month ago

Hi Nico,

Petite question. I understand that removing the custom XPath rule might fix the immediate problem, but this rule helps us a lot. It ensures we don't hardcode callout endpoint URLs in our Apex code, and instead, use Named Credentials. This is important for keeping our code secure and flexible.

I want to make sure we keep this functionality. Does MegaLinter have a similar rule or check that enforces this practice? If not, is there a way to update or adapt this rule to work with PMD7 in MegaLinter?

Your help would be really appreciated.

Thanks! Yamilet

nvuillam commented 1 month ago

@yamioliva I don't know if it is a default PMD7 rule, I'll have a look :)

ps: maybe @maximeg44 know ^^

yamioliva commented 1 month ago

@yamioliva I don't know if it is a default PMD7 rule, I'll have a look :)

ps: maybe @maximeg44 know ^^

Ok, thanks!

yamioliva commented 1 month ago

Hi Nico,

The error persists even after removing the custom rule. Here is the current error message:

Error (1): No files were found in the target. --target must contain at least one file.

Attached is a screenshot of the current error.

Any further guidance would be appreciated.

Thank you!

image

nvuillam commented 1 month ago

@yamioliva hmmm sfdx-scanner is not great for Aura / LWC ...

I'm in vacations, before we make a call when I come back, I suggest you disable this linter by adding the following line in your .mega-linter.yml :)

SALESFORCE_SFDX_SCANNER_LWC_DISABLE_ERRORS=true
yamioliva commented 1 month ago

@nvuillam no problem, as I mentioned in my initial description, I have already done that to avoid errors during deployments. However, this prevents the technical definition from being displayed. I just wanted to solve the error, but of course, it can wait ;) Thank you! Have a great holiday!