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

Make the list of options extensible #34

Open
jmini opened this issue Oct 12, 2017 · 3 comments
Open

Make the list of options extensible #34

jmini opened this issue Oct 12, 2017 · 3 comments

Comments

@jmini
Copy link
Contributor

jmini commented Oct 12, 2017

For some linter projects additional project specific options are required. The JXLint framework should be extensible in this area.

For the maven use case: the project specific Mojo (extending AbstractJxlintMojo) can contain additional parameters. The method createProgramOptions() can be overridden to handle the mapping.

For the command line use case: at the moment I have the feeling that there is too much calls of static methods. One approach could be to have a project specific subclass of Jxlint to somehow influence/replace the calls of CommandLineOptions.generateJxlintOptions() and ProgramOptionExtractor.extractProgramOptions(CommandLine) in the method Jxlint#parseArgumentsAndDispatch(String[]).

What do you think?

@selesse
Copy link
Owner

selesse commented Oct 13, 2017

Your proposed changes sound good to me. I'd be a bit curious to see what the use case is for the additional parameters in the AbstractJxlintMojo.

@jmini
Copy link
Contributor Author

jmini commented Oct 21, 2017

The additional option you might want to add really depends on the nature of the checker you write with jxlint.

One example I can imagine:
Have an additional option to define the regex pattern for the file name that should be scanned by your rules. You would implement getFilesToValidate() like this:

  @Override
  public List<File> getFilesToValidate() {
    String regex = //read the value from the option "MATCHING_FILE_REGEX"
    return FileUtils.allFilesMatching(getSourceDirectory(), regex);
  }

But this means you need to add a way to define matchingFileRegex in your Mojo or to define it from your checker CLI.

Of course this is just an example, for my htmlchecker project, I have one or two options in mind that are really specific for this checker.

Does it make sense? How would you customize the rules logic without having to add an additional option?

@selesse
Copy link
Owner

selesse commented Nov 5, 2017

I wouldn't allow customizing the logic like that without an additional option. Supplying a regex for getFilesToValidate seem like something the framework should handle through either a CLI option or a configuration file. I feel the same way about adding the ability to ignore lint failures for a certain file. If all of these things are handled by the jxlint CLI, but there's still a need to add custom options through overriding createProgramOptions, I'm OK with adding a mechanism that makes it easy.

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