rubocop-yast 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/cop/yast/builtins.rb +10 -2
- data/lib/rubocop/yast/version.rb +1 -1
- data/spec/builtins_spec.rb +33 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 440ff0688d1a756f31597e9a7bead83c60682fbb
|
4
|
+
data.tar.gz: 1e7593995a22e3ddd79838378aab1d20e848709c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5465be57775161e935f2a29adf12a91f24dcb17a8f654000d2e39b157e8e3b6483129a6c597b0de87ee5579c26718d9031c4a39887c8bb27de546cd4c10a186
|
7
|
+
data.tar.gz: 851a3358159679e9b4e10404b12e31a402a4e83ad94b3a9d3734b3b95fc87cffd522cb33096083bc54da7df78c71d93e2b48e6d8519e3e7b1176f636faf20805
|
@@ -12,12 +12,20 @@ module RuboCop
|
|
12
12
|
# white list of allowed Builtins calls
|
13
13
|
ALLOWED_FUNCTIONS = [
|
14
14
|
# locale dependent sorting in not available in Ruby stdlib
|
15
|
-
:lsort
|
15
|
+
:lsort,
|
16
|
+
# gettext helpers
|
17
|
+
:dgettext,
|
18
|
+
:dngettext,
|
19
|
+
:dpgettext
|
16
20
|
]
|
17
21
|
|
18
22
|
BUILTINS_NODES = [
|
23
|
+
# Builtins.*
|
19
24
|
s(:const, nil, :Builtins),
|
20
|
-
|
25
|
+
# Yast::Builtins.*
|
26
|
+
s(:const, s(:const, nil, :Yast), :Builtins),
|
27
|
+
# ::Yast::Builtins.*
|
28
|
+
s(:const, s(:const, s(:cbase), :Yast), :Builtins)
|
21
29
|
]
|
22
30
|
|
23
31
|
def on_send(node)
|
data/lib/rubocop/yast/version.rb
CHANGED
data/spec/builtins_spec.rb
CHANGED
@@ -2,16 +2,32 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
+
def expect_y2milestone_offense(cop)
|
6
|
+
expect(cop.offenses.size).to eq(1)
|
7
|
+
expect(cop.offenses.first.line).to eq(1)
|
8
|
+
expect(cop.messages).to eq(["Builtin call `y2milestone` is obsolete, " \
|
9
|
+
"use native Ruby function instead."])
|
10
|
+
end
|
11
|
+
|
5
12
|
describe RuboCop::Cop::Yast::Builtins do
|
6
13
|
subject(:cop) { described_class.new }
|
7
14
|
|
8
|
-
it "reports Builtins.*
|
15
|
+
it "reports Builtins.* calls" do
|
9
16
|
inspect_source(cop, ['Builtins.y2milestone("foo")'])
|
10
17
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
18
|
+
expect_y2milestone_offense(cop)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "reports Yast::Builtins.* calls" do
|
22
|
+
inspect_source(cop, ['Yast::Builtins.y2milestone("foo")'])
|
23
|
+
|
24
|
+
expect_y2milestone_offense(cop)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "reports ::Yast::Builtins.* calls" do
|
28
|
+
inspect_source(cop, ['::Yast::Builtins.y2milestone("foo")'])
|
29
|
+
|
30
|
+
expect_y2milestone_offense(cop)
|
15
31
|
end
|
16
32
|
|
17
33
|
it "ignores lsort builtin" do
|
@@ -20,4 +36,16 @@ describe RuboCop::Cop::Yast::Builtins do
|
|
20
36
|
expect(cop.offenses).to be_empty
|
21
37
|
end
|
22
38
|
|
39
|
+
it "ignores ::Builtins calls" do
|
40
|
+
inspect_source(cop, ['::Builtins.y2milestone("foo")'])
|
41
|
+
|
42
|
+
expect(cop.offenses).to be_empty
|
43
|
+
end
|
44
|
+
|
45
|
+
it "ignores Foo::Builtins calls" do
|
46
|
+
inspect_source(cop, ['Foo::Builtins.y2milestone("foo")'])
|
47
|
+
|
48
|
+
expect(cop.offenses).to be_empty
|
49
|
+
end
|
50
|
+
|
23
51
|
end
|