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

Multiple targets in lint runner #40

Merged
merged 1 commit into from
Jun 3, 2019
Merged

Conversation

PawanHegde
Copy link
Collaborator

  • Please check if the PR fulfills these requirements
  • [ ✔] Tests for the changes have been added (for bug fixes / features)
  • [ ✔] Docs have been added / updated (for bug fixes / features)
  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    Feature

  • What is the current behavior? (You can also link to an open issue here)
    Only one path can be provided to the LintRunner for linting. This could either be the path to a single file or a directory. But to lint multiple files/directory with the same rules, multiple instances of LintRunner would need to be created.

  • What is the new behavior (if this is a feature change)?
    Multiple files or folders (or a combination) can be linted with a common set of rules by a single LintRunner.

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
    Completely backward compatible

  • Other information:

@PawanHegde PawanHegde added the enhancement New feature or request label May 28, 2019
@PawanHegde PawanHegde self-assigned this May 28, 2019
this.lintRegister = lintRegister;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved most of this logic to getAllFiles. Failing to create an instance because one of the paths is wrong is not very good. Also constructors should not have complicated logic.

files.addAll(FileUtils.listFiles(file, null, true));
} else {
// TODO: Add proper logging
Logger.getGlobal().warning(basePath + " is not a valid file path");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would love feedback here. We don't want to fail the runner because one of the provided paths was wrong. But it should be more conspicuous than a log. Is it possible to include this failure as a part of the report?

for (LintRule lintRule : lintRegister.getLintRules()) {
try {
if (lintRule.getLevel() != LintLevel.IGNORE) {
Map<JSONFile, List<String>> lintReports = lintRule.lint(filesToLint.toArray(new JSONFile[filesToLint.size()]));
Map<JSONFile, List<String>> lintReports = lintRule.lint(filesToLint.toArray(new JSONFile[0]));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Better for performance. No change in semantics.

Copy link
Collaborator

@ankuagarwal ankuagarwal left a comment

Choose a reason for hiding this comment

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

Minor changes

@PawanHegde PawanHegde force-pushed the multiple_targets_in_lint_runner branch from 1d87422 to 307aeb5 Compare May 31, 2019 04:21
 - Added Unit test
 - Make LintRunner not fail on creation if path doesn't contain valid JSON files
@PawanHegde PawanHegde force-pushed the multiple_targets_in_lint_runner branch from 307aeb5 to dfa0ee8 Compare May 31, 2019 04:22
@ankuagarwal ankuagarwal merged commit a0f810a into dev Jun 3, 2019
@ankuagarwal ankuagarwal deleted the multiple_targets_in_lint_runner branch June 3, 2019 03:21
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

Successfully merging this pull request may close these issues.

None yet

2 participants