Skip to content

Commit

Permalink
Applied Rubocop rules that I like
Browse files Browse the repository at this point in the history
- Other linting configuration also applied.
- Soft-deprecating versions older than 2.3.
  • Loading branch information
halostatue committed Jan 28, 2019
1 parent 07ed577 commit 87c6b22
Show file tree
Hide file tree
Showing 36 changed files with 1,002 additions and 818 deletions.
4 changes: 3 additions & 1 deletion .autotest
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rubygems'

# vim: syntax=ruby
# vim: ft=ruby
4 changes: 4 additions & 0 deletions .fasterer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exclude_paths:
- lib/diff/lcs.rb # sort_vs_sort_by on priority_compare
- Rakefile # each_with_index vs while
- spec/spec_helper.rb
56 changes: 31 additions & 25 deletions .hoerc
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
---
exclude: !ruby/regexp '/
\.(?:
tmp |
swp
)$
tmp |
swp
)$
|
\.(?:
autotest |
byebug_history |
gemtest |
gitignore |
hoerc |
minitest.rb |
simplecov-prelude.rb)$
|
\.(?:
coveralls |
pullreview |
travis |
appveyor
)\.yml$
|
(?i:TAGS)$
|
\.(?:
DS_Store|
bundle|
git|
hg|
Expand All @@ -35,11 +16,36 @@ exclude: !ruby/regexp '/
|
[gG]emfile(?:\.lock)?
|
support\/
(?:
support |
research
)\/
|
research\/
\.(?:
appveyor |
coveralls |
fasterer |
pullreview |
rubocop.* |
travis |
unused
)\.yml$
|
(?i:TAGS)$
|
\.(?:
DS_Store |
autotest |
byebug_history |
gemtest |
gitattributes |
gitignore |
hoerc |
minitest.rb |
simplecov-prelude.rb
)$
|
\.gemspec$
|
Vagrantfile
^Vagrantfile$
/x'
120 changes: 120 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
AllCops:
DisplayCopNames: true
DisplayStyleGuide: true
ExtraDetails: true
Exclude:
- diff-lcs.gemspec
- research/**/*

Layout/AlignParameters:
EnforcedStyle: with_fixed_indentation

Layout/DotPosition:
EnforcedStyle: trailing

Layout/ExtraSpacing:
Exclude:
- spec/**/*

Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented

Metrics/LineLength:
Max: 110

Naming/FileName:
Exclude:
- lib/diff-lcs.rb

Naming/MemoizedInstanceVariableName:
Exclude: []

Naming/UncommunicativeMethodParamName:
Exclude:
- lib/diff/lcs/internals.rb
- spec/spec_helper.rb

Naming/VariableNumber:
Exclude: []

Performance/Caller:
Exclude: []

Security/MarshalLoad:
Exclude: []

Security/YAMLLoad:
Exclude: []

Style/BlockDelimiters:
EnforcedStyle: semantic
ProceduralMethods:
- trace
- assert_raises
- spec
FunctionalMethods:
- let
- subject
- add_discovery
- require_do
- it
IgnoredMethods:
- expect

Style/Documentation:
Exclude:
- lib/diff/lcs/array.rb
- lib/diff/lcs/string.rb
- spec/spec_helper.rb

# Until there is a hard drop of Ruby 1.8
Style/HashSyntax:
Enabled: false

Style/PercentLiteralDelimiters:
PreferredDelimiters:
default: ()
'%i': '()'
'%I': '()'
'%r': '{}'
'%w': '()'
'%W': '()'

Style/RescueModifier:
Enabled: false

Style/RescueStandardError:
EnforcedStyle: implicit

Style/SignalException:
EnforcedStyle: semantic

Layout/IndentHeredoc: { Enabled: false }
Metrics/AbcSize: { Enabled: false }
Metrics/BlockLength: { Enabled: false }
Metrics/BlockNesting: { Enabled: false }
Metrics/ClassLength: { Enabled: false }
Metrics/CyclomaticComplexity: { Enabled: false }
Metrics/MethodLength: { Enabled: false}
Metrics/ModuleLength: { Enabled: false}
Metrics/PerceivedComplexity: { Enabled: false }
Style/AccessModifierDeclarations: { Enabled: false }
Style/AndOr: { Enabled: false }
Style/AsciiComments: { Enabled: false }
Style/BarePercentLiterals: { Enabled: false }
Style/ClassAndModuleChildren: { Enabled: false }
Style/ClassCheck: { Enabled: false }
Style/CommentedKeyword: { Enabled: false }
Style/DoubleNegation: { Enabled: false }
Style/EmptyMethod: { Enabled: false }
Style/ExpandPathArguments: { Enabled: false }
Style/FormatString: { Enabled: false }
Style/FormatStringToken: { Enabled: false }
Style/MultilineBlockChain: { Enabled: false }
Style/ParallelAssignment: { Enabled: false }
Style/SafeNavigation: { Enabled: false }
Style/SpecialGlobalVars: { Enabled: false }
Style/SymbolArray: { Enabled: false }
Style/SymbolProc: { Enabled: false }
Style/WordArray: { Enabled: false }
28 changes: 10 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
---
language: ruby
rvm:
- 2.5.0
- 2.4.3
- 2.3.6
- 2.2.9
- 2.1.10
- 2.0.0
- 1.9.3
- 1.8.7
- ree
- 2.6.0
- 2.5.3
- 2.4.5
- 2.3.8
- jruby-9.2.5.0
- jruby-9.1.17.0
- jruby-9.0.5.0
- jruby-head
- ruby-head
- jruby-19mode
matrix:
allow_failures:
- rvm: jruby-head
- rvm: ruby-head
- rvm: 1.8.7
- rvm: ree
fast_finish: true
gemfile:
- Gemfile
before_script:
- bundle exec rake travis:before -t
script: bundle exec rake travis
after_script:
- bundle exec rake travis:after -t
notifications:
email:
recipients:
- [email protected]
on_success: change
on_failure: always
sudo: false
10 changes: 5 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# -*- ruby -*-
# frozen_string_literal: true

# NOTE: This file is present to keep Travis CI happy. Edits to it will not
# be accepted.

source "https://rubygems.org/"
source 'https://rubygems.org/'

if RUBY_VERSION < '1.9'
gem 'rdoc', '< 4'
gem 'rake', '< 11'
gem 'rdoc', '< 4'
elsif RUBY_VERSION >= '2.0'
if RUBY_ENGINE == 'ruby'
gem 'simplecov', '~> 0.7'
gem 'coveralls', '~> 0.7'
gem 'simplecov', '~> 0.7'
end
end

gemspec

# vim: syntax=ruby
# vim: ft=ruby
5 changes: 5 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.NEXT / 2019-MM-DD

* Ruby versions lower than 2.3 are soft-deprecated and will not be run as part
of the CI process any longer.

## 1.3 / 2017-01-18

* Bugs fixed:
Expand Down
1 change: 1 addition & 0 deletions Manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ docs/artistic.txt
lib/diff-lcs.rb
lib/diff/lcs.rb
lib/diff/lcs/array.rb
lib/diff/lcs/backports.rb
lib/diff/lcs/block.rb
lib/diff/lcs/callbacks.rb
lib/diff/lcs/change.rb
Expand Down
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- ruby encoding: utf-8 -*-
# frozen_string_literal: true

require 'rubygems'
require 'rspec'
Expand All @@ -11,14 +11,14 @@ Hoe.plugin :gemspec2
Hoe.plugin :git
Hoe.plugin :travis

spec = Hoe.spec 'diff-lcs' do
_spec = Hoe.spec 'diff-lcs' do
developer('Austin Ziegler', '[email protected]')

require_ruby_version '>= 1.8'

self.history_file = 'History.md'
self.readme_file = 'README.rdoc'
self.licenses = [ 'MIT', 'Artistic-2.0', 'GPL-2.0+' ]
self.licenses = ['MIT', 'Artistic-2.0', 'GPL-2.0+']

extra_dev_deps << ['hoe-doofus', '~> 1.0']
extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
Expand Down
4 changes: 3 additions & 1 deletion autotest/discover.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Autotest.add_discovery { "rspec2" }
# frozen_string_literal: true

Autotest.add_discovery { 'rspec2' }
11 changes: 7 additions & 4 deletions bin/htmldiff
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!ruby -w
#! /usr/bin/env ruby -w
# frozen_string_literal: true

require 'diff/lcs'
require 'diff/lcs/htmldiff'
Expand All @@ -10,8 +11,8 @@ rescue LoadError
end

if ARGV.size < 2 or ARGV.size > 3
$stderr.puts "usage: #{File.basename($0)} old new [output.html]"
$stderr.puts " #{File.basename($0)} old new > output.html"
warn "usage: #{File.basename($0)} old new [output.html]"
warn " #{File.basename($0)} old new > output.html"
exit 127
end

Expand All @@ -23,10 +24,12 @@ options = { :title => "diff #{ARGV[0]} #{ARGV[1]}" }
htmldiff = Diff::LCS::HTMLDiff.new(left, right, options)

if ARGV[2]
File.open(ARGV[2], "w") do |f|
File.open(ARGV[2], 'w') do |f|
htmldiff.options[:output] = f
htmldiff.run
end
else
htmldiff.run
end

# vim: ft=ruby
5 changes: 4 additions & 1 deletion bin/ldiff
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!ruby -w
#! /usr/bin/env ruby -w
# frozen_string_literal: true

require 'diff/lcs'
require 'diff/lcs/ldiff'

exit Diff::LCS::Ldiff.run(ARGV)

# vim: ft=ruby
Loading

0 comments on commit 87c6b22

Please sign in to comment.