Skip to content

Commit 91fca06

Browse files
committed
Apply rubocop fixes
1 parent 8a0702c commit 91fca06

File tree

10 files changed

+86
-139
lines changed

10 files changed

+86
-139
lines changed

.rubocop.yml

+7
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
require: rubocop-rspec
22
inherit_from: .rubocop_todo.yml
3+
4+
AllCops:
5+
TargetRubyVersion: 2.5
6+
7+
RSpec/DescribeClass:
8+
Exclude:
9+
- 'spec/**/*_spec.rb'

.rubocop_todo.yml

+9-57
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-11-26 16:16:51 +0000 using RuboCop version 0.73.0.
3+
# on 2019-11-26 16:32:38 +0000 using RuboCop version 0.73.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
@@ -41,25 +41,20 @@ Layout/EmptyLineBetweenDefs:
4141
- 'lib/gnuplot.rb'
4242
- 'test/test_gnuplot.rb'
4343

44-
# Offense count: 13
44+
# Offense count: 12
4545
# Cop supports --auto-correct.
4646
Layout/EmptyLines:
4747
Exclude:
4848
- 'lib/gnuplot.rb'
49-
- 'spec/lib/ruby_gnuplot/plot_spec.rb'
5049
- 'test/test_gnuplot.rb'
5150

52-
# Offense count: 21
51+
# Offense count: 10
5352
# Cop supports --auto-correct.
5453
# Configuration parameters: EnforcedStyle.
5554
# SupportedStyles: empty_lines, no_empty_lines
5655
Layout/EmptyLinesAroundBlockBody:
5756
Exclude:
5857
- 'examples/multiple_data_sets.rb'
59-
- 'spec/integration/arrtest_spec.rb'
60-
- 'spec/integration/histtest_spec.rb'
61-
- 'spec/integration/multtest_spec.rb'
62-
- 'spec/integration/sinwave_spec.rb'
6358
- 'test/arrtest.rb'
6459
- 'test/multtest.rb'
6560
- 'test/sinwave.rb'
@@ -102,13 +97,6 @@ Layout/IndentAssignment:
10297
Exclude:
10398
- 'lib/gnuplot.rb'
10499

105-
# Offense count: 2
106-
# Cop supports --auto-correct.
107-
# Configuration parameters: IndentationWidth.
108-
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
109-
Layout/IndentFirstArrayElement:
110-
EnforcedStyle: consistent
111-
112100
# Offense count: 2
113101
# Cop supports --auto-correct.
114102
# Configuration parameters: EnforcedStyle.
@@ -118,14 +106,13 @@ Layout/IndentationConsistency:
118106
- 'examples/multiple_data_sets.rb'
119107
- 'lib/gnuplot.rb'
120108

121-
# Offense count: 6
109+
# Offense count: 5
122110
# Cop supports --auto-correct.
123111
# Configuration parameters: Width, IgnoredPatterns.
124112
Layout/IndentationWidth:
125113
Exclude:
126114
- 'examples/3d_surface_plot.rb'
127115
- 'lib/gnuplot.rb'
128-
- 'spec/integration/multtest_spec.rb'
129116

130117
# Offense count: 2
131118
# Cop supports --auto-correct.
@@ -147,17 +134,14 @@ Layout/SpaceAroundEqualsInParameterDefault:
147134
Exclude:
148135
- 'lib/gnuplot.rb'
149136

150-
# Offense count: 9
137+
# Offense count: 6
151138
# Cop supports --auto-correct.
152139
# Configuration parameters: AllowForAlignment.
153140
Layout/SpaceAroundOperators:
154141
Exclude:
155142
- 'examples/discrete_points.rb'
156143
- 'examples/multiple_data_sets.rb'
157144
- 'ruby_gnuplot.gemspec'
158-
- 'spec/integration/arrtest_spec.rb'
159-
- 'spec/integration/histtest_spec.rb'
160-
- 'spec/integration/multtest_spec.rb'
161145
- 'test/arrtest.rb'
162146
- 'test/histtest.rb'
163147
- 'test/multtest.rb'
@@ -215,16 +199,14 @@ Layout/Tab:
215199
- 'lib/gnuplot.rb'
216200
- 'test/test_gnuplot.rb'
217201

218-
# Offense count: 9
202+
# Offense count: 7
219203
# Cop supports --auto-correct.
220204
# Configuration parameters: EnforcedStyle.
221205
# SupportedStyles: final_newline, final_blank_line
222206
Layout/TrailingBlankLines:
223207
Exclude:
224208
- 'examples/histogram.rb'
225209
- 'examples/sin_wave.rb'
226-
- 'spec/integration/multtest_spec.rb'
227-
- 'spec/integration/sinwave_spec.rb'
228210
- 'test/arrtest.rb'
229211
- 'test/histtest.rb'
230212
- 'test/multtest.rb'
@@ -308,26 +290,6 @@ Naming/VariableName:
308290
Exclude:
309291
- 'lib/gnuplot.rb'
310292

311-
# Offense count: 4
312-
RSpec/DescribeClass:
313-
Exclude:
314-
- 'spec/integration/arrtest_spec.rb'
315-
- 'spec/integration/histtest_spec.rb'
316-
- 'spec/integration/multtest_spec.rb'
317-
- 'spec/integration/sinwave_spec.rb'
318-
319-
# Offense count: 1
320-
# Configuration parameters: Max.
321-
RSpec/ExampleLength:
322-
Exclude:
323-
- 'spec/lib/ruby_gnuplot/plot_spec.rb'
324-
325-
# Offense count: 1
326-
# Configuration parameters: CustomTransform, IgnoreMethods.
327-
RSpec/FilePath:
328-
Exclude:
329-
- 'spec/lib/ruby_gnuplot/style_spec.rb'
330-
331293
# Offense count: 1
332294
Security/Eval:
333295
Exclude:
@@ -349,13 +311,7 @@ Style/AndOr:
349311
Exclude:
350312
- 'lib/gnuplot.rb'
351313

352-
# Offense count: 1
353-
# Cop supports --auto-correct.
354-
Style/BlockComments:
355-
Exclude:
356-
- 'spec/spec_helper.rb'
357-
358-
# Offense count: 8
314+
# Offense count: 6
359315
# Cop supports --auto-correct.
360316
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners.
361317
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
@@ -366,7 +322,6 @@ Style/BlockDelimiters:
366322
Exclude:
367323
- 'examples/multiple_data_sets.rb'
368324
- 'lib/gnuplot.rb'
369-
- 'spec/integration/multtest_spec.rb'
370325
- 'test/multtest.rb'
371326

372327
# Offense count: 2
@@ -535,7 +490,6 @@ Style/NumericLiterals:
535490
# SupportedStyles: predicate, comparison
536491
Style/NumericPredicate:
537492
Exclude:
538-
- 'spec/**/*'
539493
- 'lib/gnuplot.rb'
540494

541495
# Offense count: 3
@@ -593,7 +547,7 @@ Style/StringLiterals:
593547
Style/SymbolArray:
594548
EnforcedStyle: brackets
595549

596-
# Offense count: 9
550+
# Offense count: 7
597551
# Cop supports --auto-correct.
598552
# Configuration parameters: IgnoredMethods.
599553
# IgnoredMethods: respond_to, define_method
@@ -603,8 +557,6 @@ Style/SymbolProc:
603557
- 'examples/histogram.rb'
604558
- 'examples/multiple_data_sets.rb'
605559
- 'lib/gnuplot.rb'
606-
- 'spec/integration/arrtest_spec.rb'
607-
- 'spec/integration/multtest_spec.rb'
608560
- 'test/arrtest.rb'
609561
- 'test/multtest.rb'
610562

@@ -646,7 +598,7 @@ Style/ZeroLengthPredicate:
646598
Exclude:
647599
- 'lib/gnuplot.rb'
648600

649-
# Offense count: 7
601+
# Offense count: 9
650602
# Cop supports --auto-correct.
651603
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
652604
# URISchemes: http, https

spec/integration/arrtest_spec.rb

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,21 @@
1515

1616
Gnuplot.open do |gp|
1717
Gnuplot::Plot.new( gp ) do |plot|
18-
1918
plot.title "Array Plot Example"
2019
plot.ylabel "x"
2120
plot.xlabel "x^2"
2221
plot.term "postscript eps"
2322
plot.output path
2423

25-
x = (0..50).collect { |v| v.to_f }
26-
y = x.collect { |v| v ** 2 }
24+
x = (0..50).collect(&:to_f)
25+
y = x.collect { |v| v**2 }
2726

2827
plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
2928
ds.with = "linespoints"
3029
ds.notitle
3130
end
3231
end
3332
end
34-
3533
end
3634

3735
after do

spec/integration/histtest_spec.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
RandomGenerator.seed(0.17)
1616

1717
collection = (0..500).collect do
18-
(RandomGenerator.rand-0.5)**3
18+
(RandomGenerator.rand - 0.5)**3
1919
end
2020

2121
Gnuplot.open do |gp|
@@ -37,7 +37,6 @@
3737
plot.output path
3838
end
3939
end
40-
4140
end
4241

4342
after do

spec/integration/multtest_spec.rb

+7-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
Gnuplot.open do |gp|
1717
Gnuplot::Plot.new( gp ) do |plot|
18-
1918
plot.xrange "[-10:10]"
2019
plot.title "Sin Wave Example"
2120
plot.ylabel "x"
@@ -24,34 +23,30 @@
2423
plot.term "postscript eps"
2524
plot.output path
2625

27-
x = (0..50).collect { |v| v.to_f }
28-
y = x.collect { |v| v ** 2 }
26+
x = (0..50).collect(&:to_f)
27+
y = x.collect { |v| v**2 }
2928

3029
plot.data = [
31-
Gnuplot::DataSet.new( "sin(x)" ) { |ds|
30+
Gnuplot::DataSet.new( "sin(x)" ) do |ds|
3231
ds.with = "lines"
3332
ds.title = "String function"
3433
ds.linewidth = 4
35-
},
34+
end,
3635

37-
Gnuplot::DataSet.new( [x, y] ) { |ds|
36+
Gnuplot::DataSet.new( [x, y] ) do |ds|
3837
ds.with = "linespoints"
3938
ds.title = "Array data"
40-
}
39+
end
4140
]
42-
4341
end
44-
4542
end
46-
4743
end
4844

4945
after do
50-
File.delete(file_path)
46+
File.delete(file_path)
5147
end
5248

5349
it "plots expected file" do
5450
expect(file_content).to eq(fixture_content)
5551
end
5652
end
57-

spec/integration/sinwave_spec.rb

-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
Gnuplot.open do |gp|
1717
Gnuplot::Plot.new( gp ) do |plot|
18-
1918
plot.xrange "[-10:10]"
2019
plot.title "Sin Wave Example"
2120
plot.ylabel "x"
@@ -28,11 +27,8 @@
2827
ds.with = "lines"
2928
ds.linewidth = 4
3029
end
31-
3230
end
33-
3431
end
35-
3632
end
3733

3834
after do
@@ -43,4 +39,3 @@
4339
expect(file_content).to eq(fixture_content)
4440
end
4541
end
46-

spec/lib/ruby_gnuplot/plot_spec.rb

+8-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
plot.public_send(field, 'text')
55
end
66

7+
let(:expected_settings) do
8+
[
9+
[:set, field.to_s, '"text"'],
10+
[:set, field.to_s, '"new text"']
11+
]
12+
end
13+
714
it 'quotes value when setting it' do
815
expect(plot.to_gplot).to eq("set #{field} \"text\"\n")
916
end
@@ -12,10 +19,7 @@
1219
expect { plot.public_send(field, 'new text') }
1320
.to change(plot, :settings)
1421
.from([[:set, field.to_s, '"text"']])
15-
.to([
16-
[:set, field.to_s, '"text"'],
17-
[:set, field.to_s, '"new text"']
18-
])
22+
.to(expected_settings)
1923
end
2024
end
2125
end
@@ -35,7 +39,6 @@
3539
].join("\n")
3640
end
3741

38-
3942
context 'when nothing has been set' do
4043
it "returns an empty string" do
4144
expect(plot.to_gplot).to eq('')

0 commit comments

Comments
 (0)