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

Allow the --force-language PMD CLI option #265

Open
vt89 opened this issue Mar 13, 2024 · 5 comments
Open

Allow the --force-language PMD CLI option #265

vt89 opened this issue Mar 13, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@vt89
Copy link

vt89 commented Mar 13, 2024

The PMD CLI has the --force-language options to force a language to be used for all input files, irrespective of file names.

This feature allows us to use GitHub Actions for Salesforce projects.

@vt89
Copy link
Author

vt89 commented May 9, 2024

@adangel News about this feature?

@adangel
Copy link
Member

adangel commented May 16, 2024

This feature allows us to use GitHub Actions for Salesforce projects.

Can you give an example of your use case? What exactly are "Salesforce projects"?

@adangel adangel added the enhancement New feature or request label May 16, 2024
@vt89
Copy link
Author

vt89 commented May 17, 2024

@adangel
Salesforce stores XML information in files using extensions like .object, .permissionset instead of .xml.
Even if I define a PMD rule for XML language, since files do not have the .xml extension, the PMD engine does not process them.

I see the PMD cli provides the option --force-language to handle these cases and it is mentioned here: PMD CLI reference.

So, if your GitHub Action provides the --force-language input we can use it to cover the scenario I mentioned above.
I hope my explanation helps you understand my initial request

@adangel
Copy link
Member

adangel commented May 20, 2024

Thanks for sharing. I heard about .flow files, but never about .object or .permissionset (note: I'm not a apex/salesforce developer at all).

Do you know, whether these files have an official documentation?

See also pmd/pmd#4877 and especially this comment which collects existing issues around this topic.

Regarding the implementation of this feature in pmd-github-action: I assume, your salesforce project contains of: .cls files (which are Apex source files), .flow files (which are XML-files describing a "Salesforce Flow"), .object files (which are XML files for ??), .permissionset files (which are XML files for ??), and maybe others (visualforce?).
If you want to analyze your project, you would need to integrate the pmd-github-action in your workflow multiple times with different parameters... Furthermore, you can only configure sourcePath - if your XML files are in the same directory as the apex sources, this would mean, that .cls would be parsed as xml files, which will fail for sure. You would either need to use include/exclude filters in your rulesets or we need an additional parameters to specify exactly, which files should be analyzed by PMD.

Do you know of an open source sample Salesforce project, which shows such a structure and that we can reuse as a test case?

@vt89
Copy link
Author

vt89 commented May 20, 2024

Thanks @adangel for showing interest!

Official documentation is here:

In the above links, file suffixes like .object, .profile , .permissionset are mentioned and example files are also shown.
Those are three examples but there are more files with 'special' extensions.

Regarding the implementation, I got your point about having files with different extensions in the same folder.
I may try to create multiple jobs in my GitHub Workflow: one for each file extension that I want to analyze and use the sourcePath parameter.
For example, the GitHub Workflow will have one job for the .profile files and I provide the sourcePath where these files are stored, another one for permissionSet, etc.

If pmd-github-action also provide other PMD CLI parameters like --dir, --file-list then I think we will have multiple alternatives :-)

Regarding the open source sample Salesforce project I was not able to find any official one provided by Salesforce.
If you need it, I can create a new one by myself and share it with you. Let me know if it makes sense to you.

Thanks again @adangel

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

No branches or pull requests

2 participants