rubocop-crystal 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +16 -0
- data/.github/workflows/rubocop.yml +16 -0
- data/.github/workflows/test.yml +1 -1
- data/.rspec +1 -0
- data/.rubocop.yml +37 -0
- data/CHANGELOG.md +26 -0
- data/README.md +6 -2
- data/config/default.yml +36 -1
- data/lib/rubocop/cop/crystal/enumerable_reduce.rb +58 -0
- data/lib/rubocop/cop/crystal/enumerable_size.rb +31 -0
- data/lib/rubocop/cop/crystal/file_extension.rb +1 -0
- data/lib/rubocop/cop/crystal/file_read_lines.rb +115 -0
- data/lib/rubocop/cop/crystal/interpolation_in_single_quotes.rb +3 -2
- data/lib/rubocop/cop/crystal/method_name_starting_with_uppercase_letter.rb +30 -0
- data/lib/rubocop/cop/crystal/method_returning_char.rb +54 -0
- data/lib/rubocop/cop/crystal/require_at_top_level.rb +35 -0
- data/lib/rubocop/cop/crystal/require_relative.rb +6 -5
- data/lib/rubocop/cop/crystal_cops.rb +6 -0
- data/lib/rubocop/crystal/plugin.rb +28 -0
- data/lib/rubocop-crystal.rb +1 -3
- data/rubocop-crystal.gemspec +5 -2
- data/spec/rubocop/cop/crystal/enumerable_reduce_spec.rb +101 -0
- data/spec/rubocop/cop/crystal/enumerable_size_spec.rb +64 -0
- data/spec/rubocop/cop/crystal/file_read_lines_spec.rb +156 -0
- data/spec/rubocop/cop/crystal/interpolation_in_single_quotes_spec.rb +30 -0
- data/spec/rubocop/cop/crystal/method_name_starting_with_uppercase_letter_spec.rb +35 -0
- data/spec/rubocop/cop/crystal/method_returning_char_spec.rb +150 -0
- data/spec/rubocop/cop/crystal/require_at_top_level_spec.rb +42 -0
- data/spec/rubocop/cop/crystal/require_relative_spec.rb +51 -0
- data/spec/spec_helper.rb +12 -0
- data/test/string.rb +55 -0
- metadata +41 -11
- data/lib/rubocop/crystal/inject.rb +0 -15
data/test/string.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
require_relative 'harness'
|
2
2
|
|
3
|
+
=begin
|
4
|
+
The Alternative Instruction Set is a relatively unknown 32-bit RISC ISA.
|
5
|
+
It is found inside certain VIA C3 CPUs, and is responsible for emulating x86 instructions.
|
6
|
+
This isn't relevant in the slightest, but I had to put something in this comment, and I think it's cool.
|
7
|
+
=end
|
8
|
+
|
3
9
|
Test.assert_equal 'foo', "foo"
|
4
10
|
Test.assert_equal 'foo'"bar", "foobar"
|
5
11
|
Test.assert_equal "foobar", "foo" + 'bar'
|
@@ -18,3 +24,52 @@ Test.assert_equal "#{foo}""bar", 'bar' + "bar"
|
|
18
24
|
Test.assert_unequal '#{1 + 1}', '2'
|
19
25
|
|
20
26
|
Test.assert_equal '#{foo}'"bar", '#{foo}bar'
|
27
|
+
|
28
|
+
Test.assert_equal 'a'.chars[0], "a"
|
29
|
+
"bbb".each_char {|c| Test.assert_equal c, 'b' }
|
30
|
+
|
31
|
+
i = 3
|
32
|
+
|
33
|
+
while i > 0 do
|
34
|
+
i -= 1
|
35
|
+
end
|
36
|
+
Test.assert_equal 0, i
|
37
|
+
|
38
|
+
until i > 3 do
|
39
|
+
i += 1
|
40
|
+
end
|
41
|
+
Test.assert_equal 4, i
|
42
|
+
|
43
|
+
x = [0, 1, 1, 2, 3, 4]
|
44
|
+
|
45
|
+
Test.assert_equal x.length, 6
|
46
|
+
Test.assert_equal x.count, 6
|
47
|
+
Test.assert_equal x.size, 6
|
48
|
+
|
49
|
+
Test.assert_equal x.count(1), 2
|
50
|
+
Test.assert_equal x.count {|e| e > 1}, 3
|
51
|
+
|
52
|
+
Test.assert_equal x.inject { |r,v| r + v }, 11
|
53
|
+
Test.assert_equal x.inject(4) { |r,v| r - v }, -7
|
54
|
+
|
55
|
+
Test.assert_equal x.inject(:+), 11
|
56
|
+
Test.assert_equal x.reduce(:+), 11
|
57
|
+
Test.assert_equal x.inject(4, :-), -7
|
58
|
+
Test.assert_equal x.reduce(4, :-), -7
|
59
|
+
|
60
|
+
# TODO: This could be done using a true Tempfile, but Crystal removed theirs in https://github.com/crystal-lang/crystal/pull/6485.
|
61
|
+
File.write('temp', "first line\nsecond line\n\nfourth line\nfifth line")
|
62
|
+
|
63
|
+
Test.assert_equal File.readlines('temp'), ["first line\n", "second line\n", "\n", "fourth line\n", 'fifth line']
|
64
|
+
Test.assert_equal File.readlines('temp', chomp: true), ['first line', 'second line', '', 'fourth line', 'fifth line']
|
65
|
+
Test.assert_equal File.readlines('temp', ''), ["first line\nsecond line\n\n", "fourth line\nfifth line"]
|
66
|
+
Test.assert_equal File.readlines('temp', nil), ["first line\nsecond line\n\nfourth line\nfifth line"]
|
67
|
+
Test.assert_equal File.readlines('temp', 't'), ['first', " line\nsecond line\n\nfourt", "h line\nfift", 'h line']
|
68
|
+
Test.assert_equal File.readlines('temp', 'fi'), ['fi', "rst line\nsecond line\n\nfourth line\nfi", 'fth line']
|
69
|
+
Test.assert_equal File.readlines('temp', 7), ['first l', "ine\n", 'second ', "line\n", "\n", 'fourth ', "line\n", 'fifth l', 'ine']
|
70
|
+
# TODO: These are waiting on https://github.com/crystal-lang/crystal/issues/16134.
|
71
|
+
# Technically, we could fix the single-character separator by converting it to a Char, but that obviously won't work for the multi-character one, so we need to wait regardless.
|
72
|
+
# Test.assert_equal File.readlines('temp', 'e', 10), ['first line', "\nse", 'cond line', "\n\nfourth l", 'ine', "\nfifth lin", 'e']
|
73
|
+
# Test.assert_equal File.readlines('temp', 'li', 4), ["firs", "t li", "ne\ns", "econ", "d li", "ne\n\n", "four", "th l", "ine\n", "fift", 'h li', 'ne']
|
74
|
+
|
75
|
+
File.delete('temp')
|
metadata
CHANGED
@@ -1,56 +1,87 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-crystal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zopolis4
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: lint_roller
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
13
26
|
- !ruby/object:Gem::Dependency
|
14
27
|
name: rubocop
|
15
28
|
requirement: !ruby/object:Gem::Requirement
|
16
29
|
requirements:
|
17
30
|
- - ">="
|
18
31
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
32
|
+
version: 1.80.2
|
20
33
|
type: :runtime
|
21
34
|
prerelease: false
|
22
35
|
version_requirements: !ruby/object:Gem::Requirement
|
23
36
|
requirements:
|
24
37
|
- - ">="
|
25
38
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
27
|
-
description:
|
39
|
+
version: 1.80.2
|
28
40
|
email: creatorsmithmdt@gmail.com
|
29
41
|
executables: []
|
30
42
|
extensions: []
|
31
43
|
extra_rdoc_files: []
|
32
44
|
files:
|
45
|
+
- ".github/workflows/rspec.yml"
|
46
|
+
- ".github/workflows/rubocop.yml"
|
33
47
|
- ".github/workflows/test.yml"
|
34
48
|
- ".gitignore"
|
49
|
+
- ".rspec"
|
50
|
+
- ".rubocop.yml"
|
35
51
|
- CHANGELOG.md
|
36
52
|
- LICENSE
|
37
53
|
- README.md
|
38
54
|
- config/default.yml
|
39
55
|
- lib/rubocop-crystal.rb
|
56
|
+
- lib/rubocop/cop/crystal/enumerable_reduce.rb
|
57
|
+
- lib/rubocop/cop/crystal/enumerable_size.rb
|
40
58
|
- lib/rubocop/cop/crystal/file_extension.rb
|
59
|
+
- lib/rubocop/cop/crystal/file_read_lines.rb
|
41
60
|
- lib/rubocop/cop/crystal/interpolation_in_single_quotes.rb
|
61
|
+
- lib/rubocop/cop/crystal/method_name_starting_with_uppercase_letter.rb
|
62
|
+
- lib/rubocop/cop/crystal/method_returning_char.rb
|
63
|
+
- lib/rubocop/cop/crystal/require_at_top_level.rb
|
42
64
|
- lib/rubocop/cop/crystal/require_relative.rb
|
43
65
|
- lib/rubocop/cop/crystal_cops.rb
|
44
66
|
- lib/rubocop/crystal.rb
|
45
|
-
- lib/rubocop/crystal/
|
67
|
+
- lib/rubocop/crystal/plugin.rb
|
46
68
|
- rubocop-crystal.gemspec
|
69
|
+
- spec/rubocop/cop/crystal/enumerable_reduce_spec.rb
|
70
|
+
- spec/rubocop/cop/crystal/enumerable_size_spec.rb
|
71
|
+
- spec/rubocop/cop/crystal/file_read_lines_spec.rb
|
72
|
+
- spec/rubocop/cop/crystal/interpolation_in_single_quotes_spec.rb
|
73
|
+
- spec/rubocop/cop/crystal/method_name_starting_with_uppercase_letter_spec.rb
|
74
|
+
- spec/rubocop/cop/crystal/method_returning_char_spec.rb
|
75
|
+
- spec/rubocop/cop/crystal/require_at_top_level_spec.rb
|
76
|
+
- spec/rubocop/cop/crystal/require_relative_spec.rb
|
77
|
+
- spec/spec_helper.rb
|
47
78
|
- test/harness.rb
|
48
79
|
- test/string.rb
|
49
80
|
homepage: https://github.com/Zopolis4/rubocop-crystal
|
50
81
|
licenses:
|
51
82
|
- GPL-3.0-or-later
|
52
|
-
metadata:
|
53
|
-
|
83
|
+
metadata:
|
84
|
+
default_lint_roller_plugin: RuboCop::Crystal::Plugin
|
54
85
|
rdoc_options: []
|
55
86
|
require_paths:
|
56
87
|
- lib
|
@@ -65,8 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
96
|
- !ruby/object:Gem::Version
|
66
97
|
version: '0'
|
67
98
|
requirements: []
|
68
|
-
rubygems_version: 3.
|
69
|
-
signing_key:
|
99
|
+
rubygems_version: 3.7.1
|
70
100
|
specification_version: 4
|
71
101
|
summary: A RuboCop extension for converting Ruby to Crystal.
|
72
102
|
test_files: []
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module RuboCop
|
2
|
-
module Crystal
|
3
|
-
# Because RuboCop doesn't yet support plugins, we have to monkey patch in a bit of our configuration.
|
4
|
-
module Inject
|
5
|
-
def self.defaults!
|
6
|
-
path = CONFIG_DEFAULT.to_s
|
7
|
-
hash = ConfigLoader.send(:load_yaml_configuration, path)
|
8
|
-
config = Config.new(hash, path).tap(&:make_excludes_absolute)
|
9
|
-
puts "configuration from #{path}" if ConfigLoader.debug?
|
10
|
-
config = ConfigLoader.merge_with_default(config, path)
|
11
|
-
ConfigLoader.instance_variable_set(:@default_configuration, config)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|