Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

(PUP-2950) rubocop - Style/AndOR enabled for pops #2892

Merged
merged 2 commits into from Aug 6, 2014
Commits on Aug 5, 2014
  1. (PUP-2950) Fix: ensure that default layer is used when the user has n…

    vrthra committed Jul 18, 2014
    …ot provided a layer
    
    Without this patch,
    
    ```
          unless diagnostics.errors?
            @layering_config   = data['layers'] or default_layers
            @scheme_extensions = (data['extensions'] and
                      data['extensions']['scheme_handlers'] or
                      default_scheme_extensions)
          else
            @layering_config = []
            @scheme_extensions = {}
          end
    ```
    This would have resulted in @layering_config not being assigned a value if no
    layers was set. This is clearly not intented. This patch updates the behavior
    so that `@layering_config` is assigned default_layers instead
    (by changing `or` to `||`)
    
    This commit also adds test cases to verify that this case is caught. Adding the
    test case also highlighted that the constant CONFIG_CATEGORIES_MISSING was
    undefined, causing the test to fail. This commit also defines
    CONFIG_CATEGORIES_MISSING
  2. (PUP-2950) enabling rubocop Style/AndOr cop in pops directory

    vrthra committed Aug 5, 2014
    This commits enables `AndOr` cop only in lib/puppet/pops directory. This cop
    bans the use of `and` and `or` keywords in favor of `&&` and `||`. We have
    chosen this directory as a test case to evaluate the utility of enabling
    `AndOr` on the complete codebase. We inherit from the base rubocop file, so all
    the other cops remain enabled. At a future date, when `AndOr` is enabled
    systemwide, this file may be removed (if no other specialization exists on pops
    directory).
    
    It changes all code that uses `and` and `or` keywords to use `&&` and
    `||`  instead. Note that this commit only fixes the lib/puppet/pops directory.