Skip to content

Commit

Permalink
rubocop: Style/Empty* compliance
Browse files Browse the repository at this point in the history
Also disables Style/MultilineTernaryOperator
  • Loading branch information
lsegal committed Aug 11, 2016
1 parent 704265a commit cffc7d2
Show file tree
Hide file tree
Showing 26 changed files with 40 additions and 134 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Style/DotPosition:
# Disable these until we know what to do with them
Style/PredicateName: # this creates breaking changes in the API
Enabled: false
Style/MultilineTernaryOperator:
Enabled: false
Style/MutableConstant:
Enabled: false
Style/FrozenStringLiteralComment:
Expand Down
64 changes: 0 additions & 64 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,70 +309,6 @@ Style/EmptyElse:
Style/EmptyLineBetweenDefs:
Enabled: false

# Offense count: 8
# Cop supports --auto-correct.
Style/EmptyLines:
Exclude:
- 'lib/yard/cli/gems.rb'
- 'lib/yard/parser/ruby/legacy/ruby_lex.rb'
- 'lib/yard/parser/ruby/legacy/statement_list.rb'
- 'lib/yard/tags/types_explainer.rb'
- 'spec/tags/types_explainer_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/EmptyLinesAroundAccessModifier:
Exclude:
- 'lib/yard/i18n/pot_generator.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: empty_lines, no_empty_lines
Style/EmptyLinesAroundBlockBody:
Exclude:
- 'spec/handlers/decorator_handler_methods_spec.rb'
- 'spec/handlers/legacy_base_spec.rb'

# Offense count: 11
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: empty_lines, no_empty_lines
Style/EmptyLinesAroundClassBody:
Exclude:
- 'lib/yard/cli/config.rb'
- 'lib/yard/handlers/c/attribute_handler.rb'
- 'lib/yard/handlers/processor.rb'
- 'lib/yard/parser/ruby/legacy/ruby_lex.rb'
- 'lib/yard/rubygems/backports/source_index.rb'
- 'lib/yard/rubygems/hook.rb'
- 'templates/default/fulldoc/html/setup.rb'

# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: empty_lines, no_empty_lines
Style/EmptyLinesAroundModuleBody:
Exclude:
- 'lib/yard/handlers/ruby/decorator_handler_methods.rb'
- 'lib/yard/handlers/ruby/private_constant_handler.rb'
- 'lib/yard/parser/ruby/legacy/ruby_lex.rb'
- 'lib/yard/rake/yardoc_task.rb'
- 'lib/yard/rubygems/backports/source_index.rb'
- 'lib/yard/server/adapter.rb'

# Offense count: 17
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
Style/ExtraSpacing:
Exclude:
- 'benchmarks/erb_vs_erubis.rb'
- 'lib/yard/parser/ruby/legacy/ruby_lex.rb'
- 'lib/yard/parser/ruby/ruby_parser.rb'
- 'lib/yard/rake/yardoc_task.rb'
- 'lib/yard/tags/library.rb'
- 'spec/parser/ruby/legacy/token_list_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/erb_vs_erubis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def erb_with(str, x) Erubis::TinyEruby.new(str) end
rungen
end

x.report("erb") do
x.report("erb") do
eval <<-eof
module YARD; module Templates; module Template
def erb_with(str, x) ERB.new(str, nil) end
Expand Down
1 change: 0 additions & 1 deletion lib/yard/cli/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ def optparse(*args)
self.values = args if args.size >= 1
args
end

end
end
end
1 change: 0 additions & 1 deletion lib/yard/cli/gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def optparse(*args)
parse_options(opts, args)
add_gems(args)


if !args.empty? && @gems.empty?
log.error "No specified gems could be found for command"
elsif @gems.empty?
Expand Down
1 change: 0 additions & 1 deletion lib/yard/handlers/c/attribute_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ class YARD::Handlers::C::AttributeHandler < YARD::Handlers::C::Base
handle_attribute(var_name, name, read, write)
end
end

end
8 changes: 2 additions & 6 deletions lib/yard/handlers/c/handler_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,8 @@ def find_method_body(object, symbol)
next unless override_comment.file == file
name = name.gsub(/::([^:\.#]+?)\Z/, '.\1')

path = if name =~ /\.|#/ # explicit namespace in override comment
object.path
else
object.name.to_s
end

# explicit namespace in override comment
path = name =~ /\.|#/ ? object.path : object.name.to_s
if path == name || path == name.sub(/new$/, 'initialize') || path == name.sub('.', '#')
register_docstring(object, override_comment.source, override_comment)
return
Expand Down
1 change: 0 additions & 1 deletion lib/yard/handlers/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module Handlers
#
# @see Handlers::Base
class Processor

class << self
# Registers a new namespace for handlers of the given type.
# @since 0.6.0
Expand Down
2 changes: 0 additions & 2 deletions lib/yard/handlers/ruby/decorator_handler_methods.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Helper methods to assist with processing decorators.
module YARD::Handlers::Ruby::DecoratorHandlerMethods

# @overload process_decorator(*nodes, opts = {}, &block)
# Takes care of parsing method definitions passed to decorators
# as parameters, as well as parsing chained decorators.
Expand Down Expand Up @@ -126,5 +125,4 @@ def process_decorator_parameter(node, opts = {}, &block)

[{:method => method, :node => node, :name => name.to_sym}]
end

end
1 change: 0 additions & 1 deletion lib/yard/handlers/ruby/private_constant_handler.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module YARD
module Handlers
module Ruby

# Sets visibility of a constant (class, module, const)
class PrivateConstantHandler < YARD::Handlers::Ruby::Base
handles method_call(:private_constant)
Expand Down
1 change: 1 addition & 0 deletions lib/yard/i18n/pot_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def generate
end

private

def header
<<-EOH
# SOME DESCRIPTIVE TITLE.
Expand Down
26 changes: 10 additions & 16 deletions lib/yard/parser/ruby/legacy/ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ def Token(token, value = nil) # rubocop:disable Style/MethodName
[:TkRSHFT, TkOp, ">>"],
[:TkCOLON2, TkOp],
[:TkCOLON3, TkOp],
[:OPASGN, TkOp], # +=, -= etc. #
[:OPASGN, TkOp], # +=, -= etc. #
[:TkASSOC, TkOp, "=>"],
[:TkQUESTION, TkOp, "?"], #?
[:TkCOLON, TkOp, ":"], #:
[:TkQUESTION, TkOp, "?"], #?
[:TkCOLON, TkOp, ":"], #:

# [:TkfLPAREN], # func( #
# [:TkfLBRACK], # func[ #
Expand Down Expand Up @@ -282,8 +282,8 @@ def Token(token, value = nil) # rubocop:disable Style/MethodName

# { reading => token_class }
# { reading => [token_class, *opt] }
TkReading2Token = {} # rubocop:disable Style/ConstantName
TkSymbol2Token = {} # rubocop:disable Style/ConstantName
TkReading2Token = {}
TkSymbol2Token = {}

# @private
def self.def_token(token_n, super_token = Token, reading = nil, *opts)
Expand Down Expand Up @@ -321,11 +321,8 @@ def self.op_name; "#{reading}"; end

NEWLINE_TOKEN = TkNL.new(0, 0)
NEWLINE_TOKEN.set_text("\n")

end



# Lexical analyzer for Ruby source
# @private
class RubyLex
Expand Down Expand Up @@ -358,7 +355,6 @@ class RubyLex
#
# @private
class BufferedReader

attr_reader :line_num

def initialize(content)
Expand Down Expand Up @@ -519,7 +515,6 @@ def gets
l
end


def ungetc(c = nil)
@reader.ungetc(c)
end
Expand Down Expand Up @@ -631,7 +626,6 @@ def lex_init()
str = op
@ltype = "="


begin
line = ""
begin
Expand Down Expand Up @@ -902,14 +896,14 @@ def lex_int2
t.set_text("{")
end

@OP.def_rule('\\') do #'
@OP.def_rule('\\') do #'
if getc == "\n"
@space_seen = true
@continue = true
Token(TkSPACE).set_text("\\\n")
else
ungetc
Token("\\").set_text("\\") #"
Token("\\").set_text("\\") #"
end
end

Expand All @@ -927,7 +921,7 @@ def lex_int2
end
end

@OP.def_rule('$') do #'
@OP.def_rule('$') do #'
identify_gvar
end

Expand Down Expand Up @@ -1091,7 +1085,7 @@ def identify_here_document
ch = getc
indent = true
end
if /['"`]/ =~ ch # '
if /['"`]/ =~ ch # '
lt = ch
quoted = ""
while (c = getc) && c != lt
Expand All @@ -1111,7 +1105,7 @@ def identify_here_document

while ch = getc
reserve << ch
if ch == "\\" #"
if ch == "\\" #"
ch = getc
reserve << ch
elsif ch == "\n"
Expand Down
1 change: 0 additions & 1 deletion lib/yard/parser/ruby/legacy/statement_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ def process_statement_end(tk)
# Continue with the statement if we've hit a comma in a def
return if @current_block == TkDEF && peek_no_space.class == TkCOMMA


if [TkEND_OF_SCRIPT, TkNL, TkSEMICOLON].include?(tk.class) && @state == :block_statement &&
[TkRBRACE, TkEND].include?(@last_ns_tk.class) && @level == 0
@current_block = nil
Expand Down
2 changes: 1 addition & 1 deletion lib/yard/parser/ruby/ruby_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def insert_comments
end

# check upwards from line before node; check node's line at the end
((node.line - 1).downto(node.line - 2).to_a + [node.line]).each do |line|
((node.line - 1).downto(node.line - 2).to_a + [node.line]).each do |line|
comment = @comments[line]
if comment && !comment.empty?
add_comment(line, node)
Expand Down
1 change: 0 additions & 1 deletion lib/yard/rake/yardoc_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

module YARD
module Rake

# The rake task to run {CLI::Yardoc} and generate documentation.
class YardocTask < ::Rake::TaskLib
# The name of the task
Expand Down
4 changes: 0 additions & 4 deletions lib/yard/rubygems/backports/source_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def from_gems_in(*spec_dirs)
def load_specification(file_name)
Gem::Specification.load file_name
end

end

##
Expand Down Expand Up @@ -354,17 +353,14 @@ def ==(other) # :nodoc:
def dump
Marshal.dump(self)
end

end

# :stopdoc:
module Gem

##
# Cache is an alias for SourceIndex to allow older YAMLized source index
# objects to load properly.

Cache = SourceIndex unless defined?(Cache)

end
# :startdoc:
3 changes: 0 additions & 3 deletions lib/yard/rubygems/hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

module YARD
class RubygemsHook

include Gem::UserInteraction
extend Gem::UserInteraction

Expand All @@ -32,12 +31,10 @@ class RubygemsHook
attr_accessor :generate_yri

class << self

##
# Loaded version of YARD. Set by ::load_yard

attr_reader :yard_version

end

##
Expand Down
40 changes: 21 additions & 19 deletions lib/yard/serializers/yardoc_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,29 @@ def locked_for_writing?
end

def serialized_path(object)
path = case object
when String, Symbol
object = object.to_s
if object =~ /#/
object += '_i'
elsif object =~ /\./
object += '_c'
path =
case object
when String, Symbol
object = object.to_s
if object =~ /#/
object += '_i'
elsif object =~ /\./
object += '_c'
end
object.split(/::|\.|#/).map do |p|
p.gsub(/[^\w\.-]/) do |x|
encoded = '_'

x.each_byte {|b| encoded << ("%X" % b) }
encoded
end
end.join('/') + '.' + extension
when YARD::CodeObjects::RootObject
'root.dat'
else
super(object)
end
object.split(/::|\.|#/).map do |p|
p.gsub(/[^\w\.-]/) do |x|
encoded = '_'

x.each_byte {|b| encoded << ("%X" % b) }
encoded
end
end.join('/') + '.' + extension
when YARD::CodeObjects::RootObject
'root.dat'
else
super(object)
end
File.join('objects', path)
end

Expand Down
1 change: 0 additions & 1 deletion lib/yard/server/adapter.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module YARD
module Server

# Short circuits a request by raising an error. This exception is caught
# by {Commands::Base#call} to immediately end a request and return a response.
class FinishRequest < RuntimeError; end
Expand Down
Loading

0 comments on commit cffc7d2

Please sign in to comment.