8000 [css] Add new CPD language by tprouvot · Pull Request #5733 · pmd/pmd · GitHub
[go: up one dir, main page]

Skip to content

[css] Add new CPD language #5733

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

Merged
merged 11 commits into from
Jul 10, 2025
Merged

[css] Add new CPD language #5733

merged 11 commits into from
Jul 10, 2025

Conversation

tprouvot
Copy link
Contributor

Describe the PR

As discussed here, this PR adds CSS as a new language for CPD.

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

tprouvot added 3 commits May 7, 2025 16:52
- Introduced a new PMD module for CSS, including the necessary POM configuration.
- Added ANTLR grammar for CSS to support syntax parsing.
- Implemented the `CssLanguageModule` and `CssCpdLexer` for code duplication detection.
- Created unit tests for the CSS lexer functionality.
- Updated the binary distribution to include CSS as a supported language.
Copy link
github-actions bot commented May 13, 2025

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.

Regression Tester Report

(comment created at 2025-07-10 14:42:45+00:00 for 82fec8f)

@tprouvot
Copy link
Contributor Author

Hi @adangel,
Let me know if anything is missing in the PR

@adangel adangel added this to the 7.14.0 milestone May 15, 2025
@adangel adangel added the a:new-language Proposal to add a new PMD or CPD language to the main distribution label May 16, 2025
Copy link
Member
@adangel adangel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

This looks mostly good. Please fix the small suggestions I've made.

However, I'm unsure how to deal with case sensitivity, as this is not as simple as "CSS is case insensitive". Whether a token is case sensitive or not can probably only be decided after parsing. At the time of lexing, we don't know, whether the identifier is a attribute/property name or a class name/selector.
Maybe we should just remove the method "getImage" from CssCpdLexer and use the default behavior.
The grammar matches some keyword in a case insensitive way (e.g. @import or @ImPoRt will result in the same token). Maybe we should just normalize these special tokens?

tprouvot and others added 5 commits May 19, 2025 14:31
Co-authored-by: Andreas Dangel <andreas.dangel@adangel.org>
Co-authored-by: Andreas Dangel <andreas.dangel@adangel.org>
@adangel
Copy link
Member
adangel commented May 29, 2025

@tprouvot There is currently a build failure:

Liquid Exception: Undeclared javadoc namespace css in pages/pmd/languages/css.md

Could you pleas fix this by adding css to the list here:

RESERVED_NSPACES = ['ant', 'apex', 'cli', 'coco', 'core', 'cpp', 'cs', 'dart', 'dist', 'doc',
'fortran', 'gherkin', 'go', 'groovy', 'html', 'java',
'javascript', 'jsp', 'julia',
'kotlin', 'lang-test', 'lua', 'matlab', 'objectivec', 'perl', 'php', 'plsql', 'python', 'ruby', 'rust', 'scala', 'swift',
'test', 'test-schema', 'tsql', 'ui',
'modelica', 'visualforce', 'velocity', 'xml',
'vm', # pre-pmd7 name for velocity, only useful for jdoc_old or jdoc_package_old
].flat_map {|m| [m, "pmd-" + m]}

Also, how should we handle now the case sensitivity or insensitivity? Ignoring case in general looks wrong to me.

@adangel adangel modified the milestones: 7.14.0, 7.15.0 May 29, 2025
@oowekyala oowekyala self-requested a review May 30, 2025 15:29
@tprouvot
Copy link
Contributor Author

Hi @adangel
Sorry for the delay, I'll check as soon as I can

@adangel adangel modified the milestones: 7.15.0, 7.16.0 Jun 20, 2025
@tprouvot
Copy link
Contributor Author
tprouvot commented Jul 4, 2025

Hi @adangel,
Let me know if the changes I've made are ok for you, I'm opened to suggestions !

@tprouvot tprouvot requested a review from adangel July 10, 2025 13:31
Copy link
Member
@adangel adangel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good!

adangel added a commit that referenced this pull request Jul 10, 2025
adangel added a commit that referenced this pull request Jul 10, 2025
Merge pull request #5733 from tprouvot:feat/addCSStoCPD
@adangel adangel merged commit 82fec8f into pmd:main Jul 10, 2025
12 checks passed
@tprouvot
Copy link
Contributor Author

Thanks for the guidance @adangel 🙏

@tprouvot
Copy link
Contributor Author

Hi @adangel

Did the documentation was updated ?
It seems that CSS is not referenced in the supported languages

https://pmd.github.io/pmd/pmd_userdocs_cpd.html#supported-languages

@oowekyala
Copy link
Member

The release has not been published yet. It will be part of PMD 7.16.0, to appear at the end of this month.

(I'm not sure there is a snapshot documentation website, @adangel?)

@tprouvot
Copy link
Contributor Author

Thanks for your response @oowekyala 👍

@adangel
Copy link
Member
adangel commented Jul 17, 2025

So, https://pmd.github.io/pmd/pmd_userdocs_cpd.html#supported-languages is actually the snapshot version (like https://docs.pmd-code.org/snapshot/pmd_userdocs_cpd.html#supported-languages or from this PR https://pull-requests.pmd-code.org/pr-5733/82fec8fb51f498d86d05f3ba600a445bd4a6df6f/docs/pmd_userdocs_cpd.html#supported-languages )

So, you found a problem: CSS is not listed there, because it was not added there: https://github.com/pmd/pmd/blob/main/docs/pages/pmd/userdocs/cpd/cpd.md

CSS appears in the left menu however: https://docs.pmd-code.org/snapshot/pmd_languages_css.html and on this (generated) site: https://docs.pmd-code.org/snapshot/tag_CpdCapableLanguage.html

Probably we should just point to the latter page instead of maintaining the list manually in cpd.md.

adangel added a commit to adangel/pmd that referenced this pull request Jul 17, 2025
instead of maintaining another list of languages

Refs pmd#5733 (comment)
@adangel
Copy link
Member
adangel commented Jul 17, 2025

will be fixed via #5911

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:new-language Proposal to add a new PMD or CPD language to the main distribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0