Skip to content

Commit

Permalink
Get rid of ambiguous operator lints from rubocop
Browse files Browse the repository at this point in the history
* Things like array.each &:method are ambiguous in a sense that
  a simple white space would make it be a bitwise and. Adding
  parens makes it clearer, although I don't like parens so much
* Same thing goes for splates etc.
* #945
  • Loading branch information
PragTob committed Nov 15, 2014
1 parent 6a54a55 commit a1e9ca5
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lib/shoes/input_box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize(app, parent, text, styles = {}, blk = nil)
@dimensions = Dimensions.new parent, @style
@parent.add_child self
@gui = Shoes.configuration.backend_for self, @parent.gui
change &blk if blk
change(&blk) if blk
end

def state=(value)
Expand Down
6 changes: 3 additions & 3 deletions lib/shoes/internal_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def setup_gui
def_delegators :@app, :eval_with_additional_context

def clear(&blk)
current_slot.clear &blk
current_slot.clear(&blk)
end

def contents
Expand Down Expand Up @@ -132,7 +132,7 @@ def textcursor(line_height)
end

def execute_block(blk)
app.instance_eval &blk
app.instance_eval(&blk)
end

def gutter
Expand Down Expand Up @@ -167,7 +167,7 @@ def create_top_slot
end

def eval_block(execution_blk)
@top_slot.append &execution_blk
@top_slot.append(&execution_blk)
end

def create_execution_block(blk)
Expand Down
2 changes: 1 addition & 1 deletion lib/shoes/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def setup_click(blk)
end
end

click &blk
click(&blk)
end

def click(&blk)
Expand Down
2 changes: 1 addition & 1 deletion lib/shoes/list_box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize(app, parent, styles = {}, blk = nil)
@dimensions = Dimensions.new parent, @style
@parent.add_child self
@gui = Shoes.configuration.backend_for self, @parent.gui
change &blk if blk
change(&blk) if blk

choose @style[:choose]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/shoes/shape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def all_y_values(ys)

def all_values(values, current, min, max)
additional = @before_drawing ? [current] : [current, min, max]
(values + additional).map &:to_i
(values + additional).map(&:to_i)
end

def calculate_primary_dimension_value(current, new)
Expand Down
2 changes: 1 addition & 1 deletion lib/shoes/swt/common/painter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def set_rotate(graphics_context, angle, left, top)
def reset_rotate(transform, graphics_context, angle, left, top)
transform.translate left, top
transform.rotate angle
transform.translate -left, -top
transform.translate(-left, -top)
graphics_context.setTransform transform
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/shoes/swt/slot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def update_position
# #904 #905
def update_visibility
if dsl.hidden?
dsl.contents.each &:hide
dsl.contents.each(&:hide)
else
dsl.contents.each &:show
dsl.contents.each(&:show)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/shoes/text_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ def in_bounds?(*args)
end

def text=(*texts)
replace *texts[0]
replace(*texts[0])
end

def replace(*texts)
# Order here matters as well--backend#replace shouldn't rely on DSL state
# but the texts that it's passed if it needs information at this point.
@gui.replace *texts
@gui.replace(*texts)

@text = texts.map(&:to_s).join
@contents = texts
Expand Down
22 changes: 11 additions & 11 deletions lib/shoes/ui/help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def show_toc
inscription "Not findng it?\n", 'Try ', link(fg 'Search', white) { visit '/manual/999' }, '!', align: 'center', stroke: lightgray
end
stack(height: 10) {}
para *TOC
para(*TOC)
para link(fg 'to_html', green) { s.html_manual }
end
end
Expand Down Expand Up @@ -131,7 +131,7 @@ def show_page(paras, intro = false, term = nil)
if _code.include? 'te-su-to'
para fg(code(' ' + _code), maroon), NL, margin: [-10, 10, 0, 20]
else
para *highlight(' ' + _code, nil).map { |e| code e }, NL * 2, margin: [-10, 10, 0, 20]
para(*highlight(' ' + _code, nil).map { |e| code e }, NL * 2, margin: [-10, 10, 0, 20])
end
end
fill_rest_of_line
Expand All @@ -156,14 +156,14 @@ def show_paragraph(txt, intro, i, term = nil)
txt = txt.gsub("\n", ' ').gsub(/\^(.+?)\^/m, '\1').gsub(/\[\[BR\]\]/i, "\n")
txts = txt.split(/(\[\[\S+?\]\])/m).map { |s| s.split(/(\[\[\S+? .+?\]\])/m) }.flatten
case txts[0]
when /\A==== (.+) ====/ then caption *marker(Regexp.last_match[1], term), size: 24
when /\A=== (.+) ===/ then tagline *marker(Regexp.last_match[1], term), size: 12, weight: 'bold'
when /\A== (.+) ==/ then subtitle *marker(Regexp.last_match[1], term)
when /\A= (.+) =/ then title *marker(Regexp.last_match[1], term)
when /\A==== (.+) ====/ then caption(*marker(Regexp.last_match[1], term), size: 24)
when /\A=== (.+) ===/ then tagline(*marker(Regexp.last_match[1], term), size: 12, weight: 'bold')
when /\A== (.+) ==/ then subtitle(*marker(Regexp.last_match[1], term))
when /\A= (.+) =/ then title(*marker(Regexp.last_match[1], term))
when /\A\{COLORS\}/ then flow { color_page }
when /\A\{SAMPLES\}/ then flow { sample_page }
else
para *mk_deco(mk_links(txts, term).flatten), NL, (intro && i.zero?) ? { size: 16 } : ''
para(*mk_deco(mk_links(txts, term).flatten), NL, (intro && i.zero?) ? { size: 16 } : '')
txt.gsub IMAGE_RE do
image File.join(DIR, "static/#{Regexp.last_match[3]}"), eval("{#{Regexp.last_match[2] || 'margin_left: 50'}}")
fill_rest_of_line
Expand All @@ -173,9 +173,9 @@ def show_paragraph(txt, intro, i, term = nil)

def mk_links(txts, term = nil)
txts.map { |txt| txt.gsub(IMAGE_RE, '') }
.map { |txt| txt =~ /\[\[(\S+?)\]\]/m ? (t = Regexp.last_match[1].split('.'); link(ins *marker(t.last, term)) { visit "/manual/#{find_pnum t.first}" }) : txt }
.map { |txt| txt =~ /\[\[(\S+?)\]\]/m ? (t = Regexp.last_match[1].split('.'); link(ins(*marker(t.last, term))) { visit "/manual/#{find_pnum t.first}" }) : txt }
.map do|txt|
txt =~ /\[\[(\S+?) (.+?)\]\]/m ? (url = Regexp.last_match[1]; link(ins *marker(Regexp.last_match[2], term)) { visit url =~ /^http/ ? url : "/manual/#{find_pnum url}" }) :
txt =~ /\[\[(\S+?) (.+?)\]\]/m ? (url = Regexp.last_match[1]; link(ins(*marker(Regexp.last_match[2], term))) { visit url =~ /^http/ ? url : "/manual/#{find_pnum url}" }) :
(txt.is_a?(String) ? marker(txt, term) : txt)
end
end
Expand Down Expand Up @@ -227,7 +227,7 @@ def mk_sample_names
"%02d%s%s" % [first.to_i, ('-' if second), second]
end
[dummy_name, orig_name]
end.sort.map &:last
end.sort.map(&:last)
end

def find_pnum(page)
Expand Down Expand Up @@ -389,7 +389,7 @@ def mk_sidebar_list(num)
toc = []
[0..3, 4..9, 10..16, 17..32, 33..37].each do |r|
toc.push TOC_LIST[r.first][0]
toc.push(TOC_LIST[r.first + 1..r.last].to_a.map &:first) if r.include?(num)
toc.push(TOC_LIST[r.first + 1..r.last].to_a.map(&:first)) if r.include?(num)
end
toc
end
Expand Down

0 comments on commit a1e9ca5

Please sign in to comment.