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

[core] FileCollector.addFile ignores language parameter #3970

Closed
adangel opened this issue May 13, 2022 · 1 comment · Fixed by #3971
Closed

[core] FileCollector.addFile ignores language parameter #3970

adangel opened this issue May 13, 2022 · 1 comment · Fixed by #3971
Assignees
Labels
a:bug PMD crashes or fails to analyse a file.
Milestone

Comments

@adangel
Copy link
Member

adangel commented May 13, 2022

Affects PMD Version: 6.45.0

Description:

When using FileCollector.addFile(Path, Language), the language is ignored. Still the file
extension is used to determine the actual language.

See #3952 for a use case.

Example code:

        Language language = LanguageRegistry.getLanguage("html");
        try (PmdAnalysis pmd = PmdAnalysis.create(config)) {
            pmd.files().addFile(Paths.get("componentes", "myComponent.cmp"), language);
            Report report = pmd.performAnalysisAndCollectReport();
        }

Running PMD through: Other

@adangel adangel added the a:bug PMD crashes or fails to analyse a file. label May 13, 2022
@adangel adangel added this to the 6.46.0 milestone May 13, 2022
@adangel adangel modified the milestones: 6.46.0, 6.47.0 May 20, 2022
@adangel
Copy link
Member Author

adangel commented May 20, 2022

As discussed in #3971, this should also cover the case addFile(TextFile), where TextFile itself provides a specific language already.

@adangel adangel modified the milestones: 6.47.0, 6.48.0 Jun 21, 2022
@adangel adangel self-assigned this Jul 26, 2022
adangel added a commit to adangel/pmd that referenced this issue Jul 29, 2022
in order to support FileCollector.addFile with language

Fixes pmd#3970
@adangel adangel modified the milestones: 6.48.0, 6.49.0 Jul 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug PMD crashes or fails to analyse a file.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant