Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yamioliva opened this issue Jul 11, 2024 · 9 comments

Comments

@yamioliva
Copy link
Contributor

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:

  • PMD ruleset configuration errors happen.
    Or
  • Technical definitions disappear from the pipeline after applying the workaround.

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:

  • Plugin: sfdx-hardis
  • Tool: MegaLinter
  • Configuration: PMD Ruleset, Docker

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
Copy link
Member

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
Copy link
Member

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

Please can yo ucheck again ? :)

@yamioliva
Copy link
Contributor Author

yamioliva commented Jul 12, 2024 via email

@yamioliva
Copy link
Contributor Author

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
Copy link
Member

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

ps: maybe @maximeg44 know ^^

@yamioliva
Copy link
Contributor Author

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

ps: maybe @maximeg44 know ^^

Ok, thanks!

@yamioliva
Copy link
Contributor Author

yamioliva commented Jul 15, 2024

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
Copy link
Member

@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
Copy link
Contributor Author

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants