RuboCop CLI that only lints and auto-fixes code you committed by utilizing git-log and git-diff. Rfix CLI makes it possible to lint (rfix lint) and auto-fix (rfix local|origin|branch) code changes since a certain point in history. You can auto-fix code committed since creating the current branch (rfix origin) or since pushing to upstream (rfix local).
Includes a RuboCop formatter with syntax highlighting and build in hyperlinks for offense documentation.
Holds the same CLI arguments as RuboCop. Run rfix --help for a complete list or rfix for supported commands. Here are a few examples to get you started:
-
rfix localAuto-fixes commits not yet pushed to upstream -
rfix originAuto-fixes commits betweenHEADand origin branch -
rfix lintLints commits and untracked files not yet pushed to upstream
Installation
$ gem install rfix [--pre]Help
$ rfix branch "branch" # Fix changes made between HEAD and <branch>
$ rfix origin # Fix changes made between HEAD and origin branch
$ rfix local # Fix changes not yet pushed to upstream branch
$ rfix info # Display runtime dependencies and their versions
$ rfix all # Fix all files in this repository (not recommended)
$ rfix lint # Shortcut for 'rfix local --dry --untracked'
$ rfix # Displays this list of supported commandsArguments
-
--dryTurns off RuboCops autofix feature (read-only mode) -
--helpDisplays RubyCops and Rfix supported arguments -
--list-filesList all files being passed to RubyCop -
--untrackedInclude files not tracked by git -
--configConfiguration file, defaults to.rubocop.yml
Development
Setup
git clone https://github.com/oleander/rfix-rb
cd rfix-rb
bundle install
git submodule update --init --recursiveRun tests
$ bundle exec rake specOvercommit
Add the following to your .overcommit.yml, then run overcommit --install and overcommit --sign pre-commit. Lints commits not yet pushed to your upstream branch whenever git commit is ran.
PreCommit:
RFix:
enabled: true
command: ["rfix", "lint"]
description: "Lint unchanged commits using RuboCop"
parallelize: trueFrom scratch
gem install overcommit rfixcurl https://raw.githubusercontent.com/oleander/rfix-rb/master/resouces/overcommit.yml > .overcommit.ymlovercommit --installovercommit --sign pre-commit
Run overcommit --run to test the new hook.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/oleander/rfix.
License
The gem is available as open source under the terms of the MIT License.
