Skip to content

Commit 6c835e4

Browse files
committed
Lint: Layout/IndentationConsistency
1 parent 1cf3fd9 commit 6c835e4

18 files changed

+2501
-2493
lines changed

.rubocop_todo.yml

+19-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2019-02-14 11:15:10 +0100 using RuboCop version 0.64.0.
3+
# on 2019-02-14 11:18:12 +0100 using RuboCop version 0.64.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -39,7 +39,7 @@ Layout/AlignParameters:
3939
- 'lib/vips/object.rb'
4040
- 'spec/vips_spec.rb'
4141

42-
# Offense count: 238
42+
# Offense count: 265
4343
# Cop supports --auto-correct.
4444
Layout/CommentIndentation:
4545
Enabled: false
@@ -67,7 +67,7 @@ Layout/EmptyLinesAroundBlockBody:
6767
- 'spec/spec_helper.rb'
6868
- 'spec/vips_spec.rb'
6969

70-
# Offense count: 31
70+
# Offense count: 20
7171
# Cop supports --auto-correct.
7272
# Configuration parameters: EnforcedStyle.
7373
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
@@ -76,11 +76,8 @@ Layout/EmptyLinesAroundClassBody:
7676
- 'example/inheritance_with_refcount.rb'
7777
- 'lib/vips/gobject.rb'
7878
- 'lib/vips/gvalue.rb'
79-
- 'lib/vips/image.rb'
8079
- 'lib/vips/interpolate.rb'
8180
- 'lib/vips/methods.rb'
82-
- 'lib/vips/object.rb'
83-
- 'lib/vips/operation.rb'
8481

8582
# Offense count: 2
8683
# Cop supports --auto-correct.
@@ -133,12 +130,14 @@ Layout/IndentHash:
133130
- 'lib/vips/object.rb'
134131
- 'lib/vips/operation.rb'
135132

136-
# Offense count: 811
133+
# Offense count: 85
137134
# Cop supports --auto-correct.
138-
# Configuration parameters: EnforcedStyle.
139-
# SupportedStyles: normal, rails
140-
Layout/IndentationConsistency:
141-
Enabled: false
135+
# Configuration parameters: Width, IgnoredPatterns.
136+
Layout/IndentationWidth:
137+
Exclude:
138+
- 'lib/vips/image.rb'
139+
- 'lib/vips/object.rb'
140+
- 'lib/vips/operation.rb'
142141

143142
# Offense count: 4
144143
# Cop supports --auto-correct.
@@ -221,6 +220,15 @@ Layout/TrailingBlankLines:
221220
- 'spec/image_spec.rb'
222221
- 'spec/vips_spec.rb'
223222

223+
# Offense count: 227
224+
# Cop supports --auto-correct.
225+
# Configuration parameters: AllowInHeredoc.
226+
Layout/TrailingWhitespace:
227+
Exclude:
228+
- 'lib/vips/image.rb'
229+
- 'lib/vips/object.rb'
230+
- 'lib/vips/operation.rb'
231+
224232
# Offense count: 2
225233
Lint/HandleExceptions:
226234
Exclude:

example/daltonize8.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
alpha = nil
3030
if im.bands == 4
3131
alpha = im[3]
32-
im = im.extract_band 0, :n => 3
32+
im = im.extract_band 0, :n => 3
3333
end
3434

3535
begin

example/example2.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
n.times do |i|
2020
puts ""
21-
puts "call #{i} ..."
22-
out = Vips::Operation.call "black", [200, 300]
23-
if out.width != 200 or out.height != 300
24-
puts "bad image result from black"
25-
end
21+
puts "call #{i} ..."
22+
out = Vips::Operation.call "black", [200, 300]
23+
if out.width != 200 or out.height != 300
24+
puts "bad image result from black"
25+
end
2626
end
2727

2828
puts ""

example/example3.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
1.times do |i|
1515
puts "loop #{i} ..."
16-
im = Vips::Image.new_from_file ARGV[0]
17-
im = im.embed 100, 100, 3000, 3000, :extend => :mirror
18-
im.write_to_file "x.v"
16+
im = Vips::Image.new_from_file ARGV[0]
17+
im = im.embed 100, 100, 3000, 3000, :extend => :mirror
18+
im.write_to_file "x.v"
1919
end

example/example4.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313

1414
ARGV.each do |filename|
1515
im = Vips::Image.new_from_file filename
16-
profile = im.get_value "icc-profile-data"
17-
puts "profile has #{profile.length} bytes"
16+
profile = im.get_value "icc-profile-data"
17+
puts "profile has #{profile.length} bytes"
1818
end

example/inheritance_with_refcount.rb

+18-18
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ class ManagedStruct < FFI::ManagedStruct
8383

8484
def initialize(ptr)
8585
log "GLib::GObject::ManagedStruct.new: #{ptr}"
86-
super
86+
super
8787
end
8888

8989
def self.release(ptr)
9090
log "GLib::GObject::ManagedStruct.release: unreffing #{ptr}"
91-
GLib::g_object_unref(ptr) unless ptr.null?
91+
GLib::g_object_unref(ptr) unless ptr.null?
9292
end
9393

9494
end
@@ -99,7 +99,7 @@ class Struct < FFI::Struct
9999

100100
def initialize(ptr)
101101
log "GLib::GObject::Struct.new: #{ptr}"
102-
super
102+
super
103103
end
104104

105105
end
@@ -111,7 +111,7 @@ def initialize(ptr)
111111
# need the unref
112112
def initialize(ptr)
113113
log "GLib::GObject.initialize: ptr = #{ptr}"
114-
@struct = ffi_managed_struct.new(ptr)
114+
@struct = ffi_managed_struct.new(ptr)
115115
end
116116

117117
# access to the cast struct for this class
@@ -161,13 +161,13 @@ module Vips
161161

162162
def self.get_error
163163
errstr = Vips::vips_error_buffer
164-
Vips::vips_error_clear
165-
errstr
164+
Vips::vips_error_clear
165+
errstr
166166
end
167167

168168
if Vips::vips_init($0) != 0
169169
puts Vips::get_error
170-
exit 1
170+
exit 1
171171
end
172172

173173
at_exit {
@@ -180,7 +180,7 @@ def self.get_error
180180
def self.showall
181181
if $vips_debug
182182
GC.start
183-
vips_object_print_all
183+
vips_object_print_all
184184
end
185185
end
186186

@@ -214,7 +214,7 @@ class Struct < GLib::GObject::Struct
214214

215215
def initialize(ptr)
216216
log "Vips::VipsObject::Struct.new: #{ptr}"
217-
super
217+
super
218218
end
219219

220220
end
@@ -224,7 +224,7 @@ class ManagedStruct < GLib::GObject::ManagedStruct
224224

225225
def initialize(ptr)
226226
log "Vips::VipsObject::ManagedStruct.new: #{ptr}"
227-
super
227+
super
228228
end
229229

230230
end
@@ -248,7 +248,7 @@ class Struct < VipsObject::Struct
248248

249249
def initialize(ptr)
250250
log "Vips::VipsImage::Struct.new: #{ptr}"
251-
super
251+
super
252252
end
253253

254254
end
@@ -258,7 +258,7 @@ class ManagedStruct < VipsObject::ManagedStruct
258258

259259
def initialize(ptr)
260260
log "Vips::VipsImage::ManagedStruct.new: #{ptr}"
261-
super
261+
super
262262
end
263263

264264
end
@@ -276,11 +276,11 @@ def self.new_partial
276276
puts "creating image"
277277
begin
278278
x = Vips::VipsImage.new_partial
279-
puts "x = #{x}"
280-
puts ""
281-
puts "x[:parent] = #{x[:parent]}"
282-
puts ""
283-
puts "x[:parent][:description] = #{x[:parent][:description]}"
284-
puts ""
279+
puts "x = #{x}"
280+
puts ""
281+
puts "x[:parent] = #{x[:parent]}"
282+
puts ""
283+
puts "x[:parent][:description] = #{x[:parent][:description]}"
284+
puts ""
285285
end
286286

example/thumb.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@
1010
def via_memory(filename, thumbnail_width)
1111
data = IO.binread(filename)
1212

13-
thumb = Vips::Image.thumbnail_buffer data, thumbnail_width, crop: 'centre'
13+
thumb = Vips::Image.thumbnail_buffer data, thumbnail_width, crop: 'centre'
1414

15-
thumb.write_to_buffer '.jpg'
15+
thumb.write_to_buffer '.jpg'
1616
end
1717

1818
# benchmark thumbnail via files
1919
def via_files(filename, thumbnail_width)
2020
thumb = Vips::Image.thumbnail filename, thumbnail_width, crop: 'centre'
2121

22-
thumb.write_to_buffer '.jpg'
22+
thumb.write_to_buffer '.jpg'
2323
end
2424

2525
ARGV.each do |filename|
2626
puts "processing #{filename} ..."
27-
thumb = via_memory(filename, 500)
27+
thumb = via_memory(filename, 500)
2828
# thumb = via_files(filename, 500)
2929
end
3030

example/watermark.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
if im.bands >= 4 and im.interpretation == :cmyk
1818
# cmyk image
1919
n_visible_bands = 4
20-
text_colour = [0, 255, 0, 0]
20+
text_colour = [0, 255, 0, 0]
2121
elsif im.bands >= 3
2222
# rgb image
2323
n_visible_bands = 3
24-
text_colour = [255, 0, 0]
24+
text_colour = [255, 0, 0]
2525
else
2626
# mono image
2727
n_visible_bands = 1
28-
text_colour = 255
28+
text_colour = 255
2929
end
3030

3131
# split into image and alpha
3232
if im.bands - n_visible_bands > 0
3333
alpha = im.extract_band n_visible_bands, :n => im.bands - n_visible_bands
34-
im = im.extract_band 0, :n => n_visible_bands
34+
im = im.extract_band 0, :n => n_visible_bands
3535
else
3636
alpha = nil
3737
end

example/wobble.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ def wobble
1414

1515
# make a version with (0, 0) at the centre, negative values up
1616
# and left, positive down and right
17-
centre = index - [width / 2, height / 2]
17+
centre = index - [width / 2, height / 2]
1818

1919
# to polar space, so each pixel is now distance and angle in degrees
20-
polar = centre.polar
20+
polar = centre.polar
2121

2222
# scale sin(distance) by 1/distance to make a wavey pattern
23-
d = ((polar[0] * 3).sin * 10000) / (polar[0] + 1)
23+
d = ((polar[0] * 3).sin * 10000) / (polar[0] + 1)
2424

2525
# and back to rectangular coordinates again to make a set of
2626
# vectors we can apply to the original index image
27-
index += d.bandjoin(polar[1]).rect
27+
index += d.bandjoin(polar[1]).rect
2828

2929
# finally, use our modified index image to distort!
30-
mapim index
30+
mapim index
3131
end
3232
end
3333
end

lib/vips.rb

+22-22
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,26 @@ class << self
7373
def self.remove_log_handler
7474
if @glib_log_handler_id != 0 && @glib_log_domain
7575
g_log_remove_handler @glib_log_domain, @glib_log_handler_id
76-
@glib_log_handler_id = nil
76+
@glib_log_handler_id = nil
7777
end
7878
end
7979

8080
def self.set_log_domain domain
8181
GLib::remove_log_handler
8282

83-
@glib_log_domain = domain
83+
@glib_log_domain = domain
8484

8585
# forward all glib logging output from this domain to a Ruby logger
86-
if @glib_log_domain
87-
# disable this feature for now
88-
#
89-
# libvips background worker threads can issue warnings, and
90-
# since the main thread is blocked waiting for libvips to come back
91-
# from an ffi call, you get a deadlock on the GIL
92-
#
93-
# to fix this, we need a way for g_log() calls from libvips workers
94-
# to be returned via the main thread
95-
#
86+
if @glib_log_domain
87+
# disable this feature for now
88+
#
89+
# libvips background worker threads can issue warnings, and
90+
# since the main thread is blocked waiting for libvips to come back
91+
# from an ffi call, you get a deadlock on the GIL
92+
#
93+
# to fix this, we need a way for g_log() calls from libvips workers
94+
# to be returned via the main thread
95+
#
9696

9797
# @glib_log_handler_id = g_log_set_handler @glib_log_domain,
9898
# LOG_LEVEL_DEBUG |
@@ -104,13 +104,13 @@ def self.set_log_domain domain
104104
# LOG_FLAG_FATAL | LOG_FLAG_RECURSION,
105105
# LOG_HANDLER, nil
106106

107-
# we must remove any handlers on exit, since libvips may log stuff
108-
# on shutdown and we don't want LOG_HANDLER to be invoked
109-
# after Ruby has gone
110-
at_exit {
111-
GLib::remove_log_handler
112-
}
113-
end
107+
# we must remove any handlers on exit, since libvips may log stuff
108+
# on shutdown and we don't want LOG_HANDLER to be invoked
109+
# after Ruby has gone
110+
at_exit {
111+
GLib::remove_log_handler
112+
}
113+
end
114114

115115
end
116116

@@ -487,7 +487,7 @@ def initialize msg = nil
487487
@details = msg
488488
elsif Vips::vips_error_buffer != ""
489489
@details = Vips::vips_error_buffer
490-
Vips::vips_error_clear
490+
Vips::vips_error_clear
491491
else
492492
@details = nil
493493
end
@@ -575,9 +575,9 @@ def self.set_debug debug
575575
# True if this is at least libvips x.y
576576
def self.at_least_libvips?(x, y)
577577
major = version(0)
578-
minor = version(1)
578+
minor = version(1)
579579

580-
major > x || (major == x && minor >= y)
580+
major > x || (major == x && minor >= y)
581581
end
582582

583583
LIBRARY_VERSION = Vips::version_string

0 commit comments

Comments
 (0)