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

Refactor with/against Rubocop #405

Closed
wants to merge 119 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
8d32677
Implement usage of Rubocop
ZJvandeWeg Mar 10, 2015
0be8d92
Rubocop autocorrect on the bin folder
ZJvandeWeg Mar 10, 2015
e3425ef
Ruler @ 120 instead of 80 chars
ZJvandeWeg Mar 10, 2015
5894f8d
Rubocop almost passes on bin/sup
ZJvandeWeg Mar 13, 2015
48b6122
rubocop generated todo file
ZJvandeWeg Mar 17, 2015
82a4f67
Trailing whitespace rule enabled
ZJvandeWeg Mar 17, 2015
1505782
Trailing Whiteline enabled
ZJvandeWeg Mar 17, 2015
42fbb71
Cop enabled: AmbihuousRegexpLiteral
ZJvandeWeg Mar 17, 2015
c6c2852
Cop enabled: BlockAlignment
ZJvandeWeg Mar 17, 2015
b4b7d99
Cop enabled: StringConversionInInterpolation
ZJvandeWeg Mar 17, 2015
35714b4
Cop enabled: UnusedBlockArgument
ZJvandeWeg Mar 17, 2015
757f78d
Cop enabled: UnusedMethodArgument
ZJvandeWeg Mar 17, 2015
43a2745
Cop enabled: AlignHash
ZJvandeWeg Mar 17, 2015
04c14b9
Cop enabled: AccessModifierIndentation
ZJvandeWeg Mar 17, 2015
74948dd
Cop disabled: AndOr
ZJvandeWeg Mar 17, 2015
590280d
Cop enabled: HashSyntax
ZJvandeWeg Mar 17, 2015
2b14703
Cop enabled: IndentArray
ZJvandeWeg Mar 17, 2015
53cac4d
Cop enabled: AlignArray
ZJvandeWeg Mar 17, 2015
6c2cd33
Cop enabled: WordArray
ZJvandeWeg Mar 17, 2015
103625c
Cop enabled: StringLiterals
ZJvandeWeg Mar 17, 2015
3c38516
Cop enabled: Tab
ZJvandeWeg Mar 17, 2015
1918bbd
Cop enabled: TrailingComma
ZJvandeWeg Mar 17, 2015
71c1f8d
Cop enabled: SpaceAfterComma
ZJvandeWeg Mar 17, 2015
73263f2
Cop enabled: SpaceAfterControlKeyword
ZJvandeWeg Mar 17, 2015
10fea62
Cop enabled: SpaceAroundBlockParameters
ZJvandeWeg Mar 17, 2015
48ace52
Cop enabled: SpaceAroundEqualsInParameterDefault
ZJvandeWeg Mar 17, 2015
15c26bd
Cop enabled: SpaceAroundOperators
ZJvandeWeg Mar 17, 2015
17847ce
Cop enabled: SpaceBeforeBlockBraces
ZJvandeWeg Mar 17, 2015
31cdbe1
Cop enabled: SpaceBeforeComma
ZJvandeWeg Mar 17, 2015
f8c1053
Cop enabled: SpaceBeforeComment
ZJvandeWeg Mar 17, 2015
218fd70
Cop enabled: SpaceBeforeSemicolon
ZJvandeWeg Mar 17, 2015
df6756a
Cop enabled: SpaceInsideBlockBraces
ZJvandeWeg Mar 17, 2015
210c917
Cop enabled: SpaceInsideBrackets
ZJvandeWeg Mar 17, 2015
248227c
Cop enabled: SpaceInsideHashLiteralBraces
ZJvandeWeg Mar 17, 2015
4640b69
Cop enabled: SpaceInsideParens
ZJvandeWeg Mar 17, 2015
912d8f9
Cop enabled: SpaceInsideRangeLiteral
ZJvandeWeg Mar 17, 2015
81bb83b
Cop enabled: AsciiComments
ZJvandeWeg Mar 18, 2015
da46bc8
Cop disabled: NumericLiterals
ZJvandeWeg Mar 18, 2015
8c521af
Cop enabled: MethodDefParentheses
ZJvandeWeg Mar 18, 2015
fab92c2
Cop enabled: MethodCallParentheses
ZJvandeWeg Mar 18, 2015
7409bbc
Cop enabled: MultilineIfThen
ZJvandeWeg Mar 18, 2015
5419aae
Cop enabled: MultilineBlockLayout
ZJvandeWeg Mar 18, 2015
f5978de
Cop enabled: LineEndConcatenation
ZJvandeWeg Mar 18, 2015
cff44b3
Cop enabled: LeadingCommentSpace
ZJvandeWeg Mar 18, 2015
b8d21cc
Cop enabled: NegatedWhile
ZJvandeWeg Mar 18, 2015
dbe0c12
Cop enabled: MultilineOperationIndentation
ZJvandeWeg Mar 18, 2015
ea08aed
Cop enabled: InfiniteLoop
ZJvandeWeg Mar 18, 2015
fe9a98b
Cop enabled: IndentationConsistency
ZJvandeWeg Mar 18, 2015
a4da7d6
Edit rubocop test pattern
ZJvandeWeg Mar 18, 2015
7bd0683
Cop enabled: IndentationWidth
ZJvandeWeg Mar 18, 2015
4e4522b
Cop disabled: BracesAroundHashParameters
ZJvandeWeg Mar 26, 2015
384f730
Cop enabled: Blocks
ZJvandeWeg Mar 26, 2015
b7d8eae
Cop enabled: BlcokEndNewline
ZJvandeWeg Mar 26, 2015
464544f
Cop enabled: CharacterLiteral
ZJvandeWeg Mar 26, 2015
b41af6c
Cop enabled: ClassMethods
ZJvandeWeg Mar 26, 2015
e135360
Cop enabled: ClassCheck
ZJvandeWeg Mar 26, 2015
c35a786
Cop enabled: ColonMethodCall
ZJvandeWeg Mar 26, 2015
34c24bd
Cop enabled: CommentIndentation
ZJvandeWeg Mar 26, 2015
f51b3e9
Cop enabled: DeprecatedHashMethods
ZJvandeWeg Mar 26, 2015
b50bc19
Cop enabled: DotPosition
ZJvandeWeg Mar 26, 2015
695f8b5
Cop enabled: EmptyLineBetweenDefs
ZJvandeWeg Mar 26, 2015
f3edacc
Cop enabled: ElseAlignment
ZJvandeWeg Mar 26, 2015
3c55c33
Cop enabled: EmptyLines
ZJvandeWeg Mar 26, 2015
042c848
Cops enabled: EmptyLinesAround*
ZJvandeWeg Mar 26, 2015
41f1ef3
Cop enabled: EmptyLiteral
ZJvandeWeg Mar 26, 2015
57d7db0
Cop enabled: Lambda
ZJvandeWeg Mar 26, 2015
1be48d8
Cop enabled: NegatedIf
ZJvandeWeg Mar 26, 2015
d4d52ba
Cop enabled: SingleLineMethods
ZJvandeWeg Mar 26, 2015
9d8dc3e
Cop enabled: VariableInterpolation
ZJvandeWeg Mar 26, 2015
85203ea
Cop enabled: WhenThen
ZJvandeWeg Mar 26, 2015
c495550
Cop enabled: StringLiteralsInterpolation
ZJvandeWeg Mar 26, 2015
7f788e9
Cop enabled: SymbolProc
ZJvandeWeg Mar 26, 2015
81b285c
Cop enabled: NonNilCheck
ZJvandeWeg Mar 26, 2015
bf75418
Cop enabled: Not
ZJvandeWeg Mar 26, 2015
02563e0
Manual edits; Not cop
ZJvandeWeg Mar 26, 2015
c7d5164
Cop enabled: ParenthesesAroundCondition
ZJvandeWeg Mar 26, 2015
d07e2f7
Cop enabled: PercentLiteralDelimiters
ZJvandeWeg Mar 26, 2015
9c31e2b
Cop enabled: RedundantBegin
ZJvandeWeg Mar 26, 2015
06d8825
Cop enabled: RedundantReturn
ZJvandeWeg Mar 26, 2015
e04522e
Cop enabled: RedundantSelf
ZJvandeWeg Mar 26, 2015
04521ce
Cop enabled: SelfAssignment
ZJvandeWeg Mar 26, 2015
d4a1619
Cop enabled: SignalException
ZJvandeWeg Mar 26, 2015
fe1209d
Cop disabled: SpecialGlobalVars
ZJvandeWeg Mar 30, 2015
3f75be2
Cop enabled: UnlessElse -- Manually
ZJvandeWeg Mar 30, 2015
47e2fda
Cop enabled: VariableName -- Manually
ZJvandeWeg Mar 30, 2015
ec82096
Cop enabled: WhileUntilModifier -- Manually
ZJvandeWeg Mar 30, 2015
ea3c1e1
Cop enabled: TrivialAccessors
ZJvandeWeg Mar 30, 2015
95cff96
Make rubocop pass again
ZJvandeWeg Mar 30, 2015
fc1f3cc
Cop enabled: SingleLineBlockParams -- Manually
ZJvandeWeg Mar 30, 2015
e523127
Cop disabled: RescueModifier
ZJvandeWeg Mar 30, 2015
2e7fa10
Cop disabled: RegexLiteral
ZJvandeWeg Mar 30, 2015
09ad81f
Cop enabled: PerlBackrefs
ZJvandeWeg Mar 30, 2015
d2d4811
Cop enabled: OpMethod
ZJvandeWeg Mar 30, 2015
964a0a9
Cop enabled: OneLineConditional -- Manually
ZJvandeWeg Mar 30, 2015
c788ad3
Cop enabled: NestedTernaryOperator -- Manually
ZJvandeWeg Mar 30, 2015
7cc81cb
Cop enabled: AmbiguousOperator -- Manually
ZJvandeWeg Mar 30, 2015
182eb7b
Cop enabled: Loop
ZJvandeWeg Mar 30, 2015
2bb4eaf
Cop enabled: AssignmentInCondition
ZJvandeWeg Mar 30, 2015
e2cb619
Cop enabled: EndAlignment -- Manually
ZJvandeWeg Mar 30, 2015
badad4f
Cop enabled: LiteralInCondition -- Manually
ZJvandeWeg Mar 30, 2015
c7be54f
Cop enabled: ParenthesesAsGroupedExpression -- Manually
ZJvandeWeg Mar 30, 2015
a251a46
Cop enabled: ShodowingOuterLocalVariable -- Manually
ZJvandeWeg Mar 30, 2015
bc1fb8a
Cop enabled: UnderscorePrefixedVariableName
ZJvandeWeg Mar 30, 2015
2b3abf7
Cop enabled: UselessAssignment -- Manually
ZJvandeWeg Mar 31, 2015
5344bb8
Cop enabled: CaseEquality -- Manually
ZJvandeWeg Mar 31, 2015
56b4683
Cop enabled: CaseIndentataion -- Manually
ZJvandeWeg Mar 31, 2015
b7f3e85
Cop disabled: ClassAndModuleChildren
ZJvandeWeg Mar 31, 2015
1fd10dd
Cop disabled: CommentAnnotation
ZJvandeWeg Mar 31, 2015
4622da5
Cop disabled: DoubleNegation
ZJvandeWeg Mar 31, 2015
59fe089
Cop disabled: Documentation
ZJvandeWeg Mar 31, 2015
8cac47a
Cop disabled: EachWithObject
ZJvandeWeg Mar 31, 2015
ff930be
Cop enabled: EmptyElse -- Manually
ZJvandeWeg Mar 31, 2015
57e951a
Cop enabled: FileName -- Manually
ZJvandeWeg Mar 31, 2015
af4b9ba
Cop enabled: AllowedVariables
ZJvandeWeg Mar 31, 2015
14aeea4
Cop disabled: GuardClause
ZJvandeWeg Mar 31, 2015
1c623df
Cop enabled: IfUnlessModifier -- Manually
ZJvandeWeg Mar 31, 2015
1a84e48
Cop disabled: Next
ZJvandeWeg Mar 31, 2015
2d5eb15
Manual changes reverted; gets sup running again
ZJvandeWeg Apr 1, 2015
585254c
Load all thread action works again in inbox mode
ZJvandeWeg Apr 6, 2015
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
75 changes: 75 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
inherit_from: .rubocop_todo.yml

AllCops:
Exclude:
- 'tmp/**/*'
DisplayCopNames: true

# Config of cops
Lint/AssignmentInCondition:
AllowSafeAssignment: true

Style/EmptyLineBetweenDefs:
AllowAdjacentOneLineDefs: true

Style/Semicolon:
AllowAsExpressionSeparator: true

Style/TrivialAccessors:
ExactNameMatch: true

Style/FileName:
Exclude: [sup-add, sup-config, sup-dump, sup-import-dump, sup-psych-ify-config-files, sup-recover-sources,
sup-sync, sup-sync-back-maildir, sup-tweak-labels]

Style/GlobalVars:
AllowedVariables: [$config, $cursing, $die, $encoding, $last_fn, $opts, $terminal]
# Disabled cops

Style/AndOr:
Enabled: false

Style/NumericLiterals:
Enabled: false

Style/BracesAroundHashParameters:
Enabled: false

Style/SingleLineMethods:
Enabled: false

# Even though there's a --auto-correct available, this
# changed behavior.
Style/SpecialGlobalVars:
Enabled: false

Style/RescueModifier:
Enabled: false

Style/RegexpLiteral:
Enabled: false

Style/ClassAndModuleChildren:
Enabled: false

Style/CommentAnnotation:
Enabled: false

Style/DoubleNegation:
Enabled: false

Style/Documentation:
Enabled: false

Style/EachWithObject:
Enabled: false

Style/FileName:
Enabled: false

Style/GuardClause:
Enabled: false

# Detection at this point flawed.. Maybe later
Style/Next:
Enabled: false
83 changes: 83 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Offense count: 3
Lint/Eval:
Enabled: false

# Offense count: 5
Lint/HandleExceptions:
Enabled: false

# Offense count: 10
Lint/RescueException:
Enabled: false

# If I recall correctly, this one is fixed allready by another PR. Remove me later.
# Offense count: 1
Lint/UselessElseWithoutRescue:
Enabled: false

# Offense count: 179
Metrics/AbcSize:
Max: 140

# Offense count: 7
Metrics/BlockNesting:
Max: 5

# Offense count: 25
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 1000

# Offense count: 90
Metrics/CyclomaticComplexity:
Max: 40

# Offense count: 613
# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Max: 213

# Offense count: 199
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 100

# Offense count: 5
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
Max: 7

# Offense count: 82
Metrics/PerceivedComplexity:
Max: 41

# Offense count: 8
Style/AccessorMethodName:
Enabled: false

# Offense count: 7
Style/ClassVars:
Enabled: false

# Offense count: 1
Style/FlipFlop:
Enabled: false

# Offense count: 18
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/FormatString:
Enabled: false

# Offense count: 4
Style/MultilineBlockChain:
Enabled: false

# Offense count: 25
# Configuration parameters: NamePrefix, NamePrefixBlacklist.
Style/PredicateName:
Enabled: false

# Offense count: 4
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/RaiseArgs:
Enabled: false
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ before_install:
- sudo apt-get install -qq uuid-dev uuid libncursesw5-dev libncursesw5 gnupg2 pandoc
- git submodule update --init --recursive

script: bundle exec rake travis
script: bundle exec rake travis test
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org/'

if !RbConfig::CONFIG['arch'].include?('openbsd')
unless RbConfig::CONFIG['arch'].include?('openbsd')
gem 'xapian-ruby', '~> 1.2.15'
end

Expand Down
33 changes: 19 additions & 14 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
require 'rubygems'
require 'rake/testtask'
require "bundler/gem_tasks"
require 'bundler/gem_tasks'
require 'rubocop/rake_task'

Rake::TestTask.new(:test) do |test|
Rake::TestTask.new(:minitest) do |test|
test.libs << 'test'
test.test_files = FileList.new('test/**/test_*.rb')
test.verbose = true
end
task :default => :test
desc 'Run tests'

task :build => [:man]
task :travis => [:test, :build]
RuboCop::RakeTask.new(:rubocop)
desc 'Run Rubocop Linter'

task test: [:minitest, :rubocop]
task default: [:test]

task build: [:man]
task travis: [:test, :build]

def test_pandoc
return system("pandoc -v > /dev/null 2>&1")
system('pandoc -v > /dev/null 2>&1')
end

task :man do
puts "building manpages from wiki.."
puts 'building manpages from wiki..'
unless test_pandoc
puts "no pandoc installed, needed for manpage generation."
puts 'no pandoc installed, needed for manpage generation.'
return
end

# test if wiki is cloned
unless Dir.exist? 'doc/wiki/man'
puts "wiki git repository is not cloned in doc/wiki, try: git submodule update --init."
puts 'wiki git repository is not cloned in doc/wiki, try: git submodule update --init.'
return
end

unless Dir.exist? 'man'
Dir.mkdir 'man'
end
Dir.mkdir 'man' unless Dir.exist? 'man'

Dir.glob("doc/wiki/man/*.md").each do |md|
Dir.glob('doc/wiki/man/*.md').each do |md|
m = /^.*\/(?<manpage>[^\/]*)\.md$/.match(md)[:manpage]
puts "generating manpage for: #{m}.."
r = system "pandoc -s -f markdown -t man #{md} -o man/#{m}"
Expand All @@ -46,7 +51,7 @@ task :man do
end

task :clean do
['man', 'pkg'].each do |d|
%w(man pkg).each do |d|
puts "cleaning #{d}.."
FileUtils.rm_r d if Dir.exist? d
end
Expand Down
Loading