Skip to content

[core] Language properties CLI surface syntax #2947

@oowekyala

Description

@oowekyala

This is about the part of #2518 that could be targeted to master (6.31.0) to accompany #2864

This ticket is just about to add this form of argument to the cli: -L<langId>:<propName> <value>, or some form of this depending on what JCommander supports well

I don't think we should aim to implement the data flow from the command-line arg parsing to the language instance in this ticket. It's probably difficult to do on master, easier on the 7.0 branch, and will stay alive longer on that branch. So this part is still in #2518

Instead, what #2864, and #2830 do is to add attributes to the ParserOptions, as this is what parsers get as their input. Linking the CLI to the ParserOptions can be done with a system property as a swap, which is mostly already implemented in #2864 I think

TODO

  • Find out a satisfying syntax with JCommander and implement it (based on [vf] Provide expression type information to Visualforce rules to avoid false positives #2864)
  • Document
    • on the website CLI reference
    • we probably need some new page that explains language by language what sets them apart (which language versions, which properties, other details or useful info for people writing rules maybe, and stuff like links to javadoc)
    • in the release notes
    • in the CLI --help?

This should probably be prominently marked experimental everywhere it is mentioned for at least a few releases, maybe even until PMD 7. But the api surface is I think quite small since it's just one form of arguments.

I think this task could shave a big chunk off #2518, because the user documentation will probably not need to change too much

See also:

// TODO this should be reused when implementing the CLI
public static Map<Language, LanguagePropertyBundle> derivePropertiesFromStrings(
Map<Language, Properties> stringProperties,
PmdReporter reporter
) {

// TODO replace those with actual language properties when the
// CLI syntax is implemented.
props.setProperty(LanguagePropertyBundle.SUPPRESS_MARKER, config.getSuppressMarker());
if (props instanceof JvmLanguagePropertyBundle) {
((JvmLanguagePropertyBundle) props).setClassLoader(config.getClassLoader());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    an:enhancementAn improvement on existing features / rulesin:cliAffects the PMD Command Line Interface

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions