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

Allow to filter with a regex pattern with the addition of whitelist pattern option to Yaml Lint task #528

Merged
merged 4 commits into from
Aug 2, 2018

Conversation

DidYoun
Copy link
Contributor

@DidYoun DidYoun commented Jul 24, 2018

Q A
Branch master for features and deprecations
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Documented? yes
Fixed tickets #527

As for PRs :

This PR add a new whitelist_patternsoption to Yamllint task. It will be used to filter files to be validated.

Example for a Symfony, validate PHP files only in src/ directory

yamllint:
    ignore_patterns: []
    object_support: false
    exception_on_invalid_type: false
    parse_constant: false
    parse_custom_tags: false
    whitelist_patterns: ["^src/(.*)"]

New Task Checklist:

  • Is the README.md file updated?
  • Are the dependencies added to the composer.json suggestions?
  • Is the doc/tasks.md file updated?
  • Are the task parameters documented?
  • Is the task registered in the tasks.yml file?
  • Does the task contains phpspec tests?
  • Is the configuration having logical allowed types?
  • Does the task run in the correct context?
  • Is the run() method readable?
  • Is the run() method using the configuration correctly?
  • Are all CI services returning green?

$files = $context->getFiles()->name('/\.(yaml|yml)$/i');
/** @var array $config */
$config = $this->getConfiguration();
$whitelistPatterns = isset($config['whitelist_patterns']) ? $config['whitelist_patterns'] : [];
Copy link
Contributor

Choose a reason for hiding this comment

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

$whitelistPatterns = $config['whitelist_patterns'];

isset check is done in getConfigurableOptions()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, thanks for the reply.
I've deleted the isset check on $whitelistPatterns

/** @var array $config */
$config = $this->getConfiguration();
$whitelistPatterns = isset($config['whitelist_patterns']) ? $config['whitelist_patterns'] : [];
$extensionPattern = '/\.(yaml|yml)$/i';
Copy link
Contributor

Choose a reason for hiding this comment

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

In most tasks, this variable is named $extensions (for consistency)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The variable name has been changed : $extensionPattern -> $extensions

@DidYoun
Copy link
Contributor Author

DidYoun commented Aug 2, 2018

Hi,

Requested changes have been done. Could you check the pull request again ? Thanks 😃

@Landerstraeten
Copy link
Contributor

Hi @DidYoun, Thanks for the PR! The changes look good.

@Landerstraeten Landerstraeten merged commit fdfd668 into phpro:master Aug 2, 2018
@Landerstraeten Landerstraeten added this to the Version 0.14.2 milestone Aug 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants