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

Ignore data types where trailing commas are illegal #25

Merged
merged 2 commits into from
Sep 30, 2022

Commits on Sep 30, 2022

  1. (voxpupuliGH-16) Ignore data type arrays

    Prior to this commit the plugin would evaluate a data types value array as a
    standard array type. This would cause the line to be flagged as invalid.
    
    When running with `--fix`, the plugin would attempt to fix this condition
    by appending a comma token to the final element of the array.i
    
    According to puppet-syntax this is invalid.
    
    For example:
    
    Vaid:
    
    ```
      Enum[
        'enforcing',
        'permissive',
        'disabled'
      ] $selinux_setting = 'permissive',
    
    ```
    
    Invalid:
    
    ```
      Enum[
        'enforcing',
        'permissive',
        'disabled',
      ] $selinux_setting = 'permissive',
    
    ```
    
    Running `bundle exec rake syntax` post fix returns the following
    error:
    
    ```
    Could not parse for environment *root*: Syntax error at ']' (file: ./test.pp, line: 7, column: 1)
    ```
    
    The above is not true for normal array declarations. Puppet syntax will
    happily parse a normal array with a trailing comma.
    
    Valid auto-fix from the plugin
    
    ```
     $test = [
        'one',
        'two',
        'three',
      ]
    ```
    
    This commit fixes the above by adding functionality to check whether the current
    `array_index` is actually an array of data type values.
    
    If the condition is true we skip the current iteration so that it will
    not be linted.
    chelnak committed Sep 30, 2022
    Configuration menu
    Copy the full SHA
    e9b4880 View commit details
    Browse the repository at this point in the history
  2. (voxpupuliGH-16) Update tests

    This commit updates the existing spec tests with examples that
    demonstrate how the linter would ignore data type values.
    chelnak committed Sep 30, 2022
    Configuration menu
    Copy the full SHA
    e425048 View commit details
    Browse the repository at this point in the history