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

Add option to enable rubocop todos #19

Merged
merged 2 commits into from
Feb 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ Travis uses a .travis.yml file in the root of your repository to learn about you
| Key | Description |
| :------------- |:--------------|
| ruby versions |Define the ruby versions on which you want your builds to be executed.|
| bunder\_args |Define any arguments you want to pass through to bundler. The default is ```--without system_tests``` which avoids installing unnessesary gems.|
| env |Allows you to set any environment variables for the travis build. Currently includes setting the Puppet gem version alongside the variable ```CHECK``` which determines what tests to run.|
|docker_sets |Allows you to configure sets of docker to run your tests on. For example, if I wanted to run on a docker instance of Ubuntu I would add ```set: docker/ubuntu-14.04``` to my docker\_sets attribute.|
|docker_defaults |Defines what values are used as default when using the ```docker_sets``` definition. Includes ruby version, sudo being enabled, the distro, the services, the env variables and the script to execute.|
| bunder\_args |Define any arguments you want to pass through to bundler. The default is `--without system_tests` which avoids installing unnessesary gems.|
| env |Allows you to set any environment variables for the travis build. Currently includes setting the Puppet gem version alongside the variable `CHECK` which determines what tests to run.|
|docker_sets |Allows you to configure sets of docker to run your tests on. For example, if I wanted to run on a docker instance of Ubuntu I would add `set: docker/ubuntu-14.04` to my docker\_sets attribute.|
|docker_defaults |Defines what values are used as default when using the `docker_sets` definition. Includes ruby version, sudo being enabled, the distro, the services, the env variables and the script to execute.|
|includes |Ensures that the .travis file includes the following checks by default: Rubocop, Puppet Lint, Metadata Lint.|


Expand All @@ -54,29 +54,30 @@ Travis uses a .travis.yml file in the root of your repository to learn about you

| Key | Description |
| :------------- |:--------------|
|appveyor\_bundle\_install|Defines the bundle install command for the appveyor execution run. In our case we use bundle install ```--without system_tests``` as default, therefore avoiding redundant gem installation.|
|appveyor\_bundle\_install|Defines the bundle install command for the appveyor execution run. In our case we use bundle install `--without system_tests` as default, therefore avoiding redundant gem installation.|
|environment|Defines any environment variables wanted for the job run. In our case we default to the latest Puppet 4 gem version.|
|matrix|This defines the matrix of jobs to be executed at runtime. Each defines environment variables for that specific job run. In our defaults we have a Ruby version specfied, followed by the check that will be run for that job.|
|test\_script|This defines the test script that will be executed. For our purposes the default is set to ```bundle exec rake %CHECK%```. As appveyor iterates through the test matrix as we defined above, it resolves the variable CHECK and runs the resulting command. For example, our last test script would be executed as ```bundle exec rake spec```, which would run the spec tests of the module.|
|test\_script|This defines the test script that will be executed. For our purposes the default is set to `bundle exec rake %CHECK%`. As appveyor iterates through the test matrix as we defined above, it resolves the variable CHECK and runs the resulting command. For example, our last test script would be executed as `bundle exec rake spec`, which would run the spec tests of the module.|

### Rakefile

>[Rake](https://github.com/ruby/rake) is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax within the Rakefile, present in the root directory of the code repository. Within modules context Rake tasks are used quite frequently, from ensuring the integrity of a module, running validation and tests, to tasks for releasing modules.

| Key | Description |
| :------------- |:--------------|
|default\_disabled\_lint\_checks| Defines any checks that are to be disabled by default when running lint checks. As default we disable the ```--relative``` lint check, which compares the module layout relative to the module root. |
|default\_disabled\_lint\_checks| Defines any checks that are to be disabled by default when running lint checks. As default we disable the `--relative` lint check, which compares the module layout relative to the module root. |

### .rubocop.yml

>[RuboCop](https://github.com/bbatsov/rubocop) is a Ruby static code analyzer. We use Rubocop to enforce a level of quility and consistancy within Ruby code. Rubocop can be configured within .rubocop.yml which is located in the root directory of the code repository. Rubocop works by defining a sanitized list of cops that'll cleanup a code base without much effort, all of which support autocorrect and that are fairly uncontroversial across wide segments of the Community.

| Key | Description |
| :------------- |:--------------|
|selected\_profile|Allows you to define which profile is used by default, which is set to ```strict```, which is fully defined within the ```profiles``` section.|
|default\_configs |Allows you to define the default configuration of which cops will run. Includes the full name of the cop followed by a description of it and an enforced style. Can also make use of the key ```excludes``` to exclude any files from that specific cop.|
|include\_todos|Allows you to use rubocop's "TODOs" to temporarily skip checks by setting this to `true`. See rubocop's `--auto-gen-config` option for details. Defaults to `false`.|
|selected\_profile|Allows you to define which profile is used by default, which is set to `strict`, which is fully defined within the `profiles` section.|
|default\_configs |Allows you to define the default configuration of which cops will run. Includes the full name of the cop followed by a description of it and an enforced style. Can also make use of the key `excludes` to exclude any files from that specific cop.|
|cleanup\_cops |Defines a set of cleanup cops to then be included within a rubocop profile. Cops are defined by their full name, and further configuration can be done by specifying secondary keys. By default we specify a large amount of cleanup cops using their default configuration.|
|profiles |Defines the profiles that can be enabled and used within rubocop through the ```selected_profile``` option. By default we have set up three profiles: cleanups\_only, strict, hardcore and off.|
|profiles |Defines the profiles that can be enabled and used within rubocop through the `selected_profile` option. By default we have set up three profiles: cleanups\_only, strict, hardcore and off.|


### Gemfile
Expand Down
4 changes: 4 additions & 0 deletions moduleroot/.rubocop.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ defaults = {
},
}

if @configs['include_todos']
defaults['inherit_from'] = '.rubocop_todo.yml'
end

require 'deep_merge/core'
profile = @configs['profiles'][@configs['selected_profile']]
configs = defaults.dup
Expand Down