Skip to content

Instantly share code, notes, and snippets.

@backus
backus / rubocop.yml
Created July 27, 2015 03:35
Some of my rubocop preferences
AllCops:
Include:
- "**/*.rake"
- "**/Gemfile"
- "**/Rakefile"
Exclude:
- "vendor/**/*"
- "db/**/*"
DisplayCopNames: true
RunRailsCops: true
@backus
backus / reek-rubyspec.txt
Created September 30, 2015 05:58
reek + rubyspec
$ reek -v
reek 3.5.0
$ tree -d
.
├── command_line
│   ├── fixtures
│   └── shared
├── core
│   ├── argf
│   │   ├── fixtures
$ CI=true be mutant -j1 -I . -r mutant-freezer --use rspec 'Foo*'Mutant configuration:
Matcher: #<Mutant::Matcher::Config match_expressions: [Foo*]>
Integration: Mutant::Integration::Rspec
Expect Coverage: 100.00%
Jobs: 1
Includes: ["."]
Requires: ["mutant-freezer"]
(00/08) 100% - killtime: 0.00s runtime: 0.00s overhead: 0.00s
(07/08) 87% - killtime: 0.18s runtime: 1.01s overhead: 0.83s
Foo#bar:/Users/johnbackus/Dropbox/coding/gists/mutant-freezer.rb:13
---
Style/BarePercentLiterals:
EnforcedStyle: percent_q
SupportedStyles:
- percent_q
- bare_percent
@backus
backus / example.rb
Created November 18, 2015 03:24
Shoulda matchers `allow_value` bug
require 'active_model'
class Example
include ActiveModel::Model
validates :foo, inclusion: [1]
attr_accessor :foo
end
@backus
backus / happymapper-nested-benchmark.rb
Last active December 1, 2015 21:05
HappyMapper flat vs. nested benchmark
XML = <<-EXML.freeze
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<foo>
<bar>
<baz>
<qux>
<quux>
<corge>
<grault>
<garply>
@backus
backus / Gemfile
Created December 26, 2015 08:44
RSpec 3.4.1 crash. Run with --profile
gem 'rspec', '~> 3.4.0'
gem 'rspec-core', '~> 3.4.1'
@backus
backus / generate-rubocop-excludes.rb
Last active October 8, 2016 23:24
Rubocop's --auto-gen-config changes your settings for certain cops. For example, if you have one line of code which has a LineLength of 150 characters then it is going to set your Metrics/LineLength config to Max: 150. This script instead generates a list of files to exclude only and does not lower your standards
#!/usr/bin/env ruby
gem 'slop', '4.2.1'
require 'slop'
require 'pathname'
require 'json'
require 'yaml'
source 'https://rubygems.org'
ruby '2.3.0'
gem 'rubocop', '0.38.0'
@backus
backus / comments.rb
Created June 18, 2016 22:54
Detect duplicate comments
require 'parser/current'
require 'pathname'
require 'concord'
class Comment
include Equalizer.new(:text)
def initialize(path, comment)
@path = path