sonicop 26.8.101

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.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/CONFORMANCE.md +109 -0
  3. data/Cargo.lock +975 -0
  4. data/Cargo.toml +40 -0
  5. data/LICENSE +21 -0
  6. data/NOTICE +7 -0
  7. data/README.ja.md +161 -0
  8. data/README.md +173 -0
  9. data/config/default.yml +6305 -0
  10. data/exe/sonicop +7 -0
  11. data/ext/sonicop/extconf.rb +38 -0
  12. data/lib/sonicop/runner.rb +67 -0
  13. data/lib/sonicop/version.rb +6 -0
  14. data/lib/sonicop.rb +8 -0
  15. data/licenses/RUBOCOP.txt +20 -0
  16. data/licenses/TREE_SITTER_RUBY.txt +21 -0
  17. data/src/cli.rs +940 -0
  18. data/src/config/inheritance.rs +332 -0
  19. data/src/config/loader.rs +117 -0
  20. data/src/config/mod.rs +461 -0
  21. data/src/config/paths.rs +436 -0
  22. data/src/config/plugin.rs +247 -0
  23. data/src/config/store.rs +141 -0
  24. data/src/cop_name.rs +71 -0
  25. data/src/diagnostic.rs +205 -0
  26. data/src/directives.rs +305 -0
  27. data/src/engine.rs +734 -0
  28. data/src/formatter.rs +684 -0
  29. data/src/lib.rs +42 -0
  30. data/src/main.rs +3 -0
  31. data/src/ruby_version.rs +393 -0
  32. data/src/rules/layout/empty_line_after_magic_comment.rs +49 -0
  33. data/src/rules/layout/end_of_line.rs +35 -0
  34. data/src/rules/layout/line_length.rs +167 -0
  35. data/src/rules/layout/mod.rs +13 -0
  36. data/src/rules/layout/space_after_comma.rs +32 -0
  37. data/src/rules/layout/space_around_operators.rs +104 -0
  38. data/src/rules/layout/space_inside_parens.rs +100 -0
  39. data/src/rules/layout/support.rs +23 -0
  40. data/src/rules/layout/trailing_empty_lines.rs +38 -0
  41. data/src/rules/layout/trailing_whitespace.rs +26 -0
  42. data/src/rules/lint/duplicate_methods.rs +72 -0
  43. data/src/rules/lint/mod.rs +7 -0
  44. data/src/rules/lint/syntax.rs +200 -0
  45. data/src/rules/lint/unused_block_argument.rs +74 -0
  46. data/src/rules/lint/useless_assignment.rs +104 -0
  47. data/src/rules/metrics/block_length.rs +39 -0
  48. data/src/rules/metrics/class_length.rs +34 -0
  49. data/src/rules/metrics/method_length.rs +10 -0
  50. data/src/rules/metrics/mod.rs +10 -0
  51. data/src/rules/metrics/module_length.rs +17 -0
  52. data/src/rules/metrics/parameter_lists.rs +21 -0
  53. data/src/rules/metrics/support.rs +105 -0
  54. data/src/rules/mod.rs +380 -0
  55. data/src/rules/naming/ascii_identifiers.rs +17 -0
  56. data/src/rules/naming/constant_name.rs +49 -0
  57. data/src/rules/naming/method_name.rs +51 -0
  58. data/src/rules/naming/mod.rs +9 -0
  59. data/src/rules/naming/support.rs +22 -0
  60. data/src/rules/naming/variable_name.rs +50 -0
  61. data/src/rules/security/eval.rs +170 -0
  62. data/src/rules/security/mod.rs +6 -0
  63. data/src/rules/style/frozen_string_literal_comment.rs +56 -0
  64. data/src/rules/style/hash_syntax.rs +63 -0
  65. data/src/rules/style/mod.rs +9 -0
  66. data/src/rules/style/numeric_literals.rs +59 -0
  67. data/src/rules/style/redundant_return.rs +143 -0
  68. data/src/rules/style/semicolon.rs +48 -0
  69. data/src/rules/style/string_literals.rs +74 -0
  70. data/src/rules/support.rs +31 -0
  71. data/src/source.rs +118 -0
  72. metadata +117 -0
data/exe/sonicop ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'sonicop'
5
+
6
+ Sonicop::Runner.run
7
+
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mkmf'
4
+ require 'rbconfig'
5
+ require 'shellwords'
6
+
7
+ cargo = find_executable('cargo')
8
+ abort 'cargo is required to build the sonicop source gem' unless cargo
9
+
10
+ root = File.expand_path('../..', __dir__)
11
+ executable = Gem.win_platform? ? 'sonicop.exe' : 'sonicop'
12
+ installed_executable = Gem.win_platform? ? 'sonicop-bin.exe' : 'sonicop-bin'
13
+ binary = File.join(root, 'target', 'release', executable)
14
+
15
+ create_makefile('sonicop/native')
16
+
17
+ File.open('Makefile', 'a') do |makefile|
18
+ makefile.write(<<~MAKEFILE)
19
+
20
+ SONICOP_ROOT = #{Shellwords.escape(root)}
21
+ SONICOP_CARGO = #{Shellwords.escape(cargo)}
22
+ SONICOP_BINARY = #{Shellwords.escape(binary)}
23
+ SONICOP_EXE = #{installed_executable}
24
+
25
+ .PHONY: sonicop-build sonicop-install
26
+
27
+ all: sonicop-build
28
+
29
+ sonicop-build:
30
+ cd $(SONICOP_ROOT) && $(SONICOP_CARGO) build --release --locked
31
+
32
+ install-so: sonicop-install
33
+
34
+ sonicop-install: sonicop-build
35
+ $(MAKEDIRS) $(sitearchdir)
36
+ $(INSTALL_PROG) $(SONICOP_BINARY) $(sitearchdir)/$(SONICOP_EXE)
37
+ MAKEFILE
38
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rbconfig'
4
+ require 'rubygems'
5
+
6
+ module Sonicop
7
+ module Runner
8
+ module_function
9
+
10
+ def run(arguments = ARGV)
11
+ binary = find_binary
12
+ abort <<~MESSAGE unless binary
13
+ Sonicop's native executable was not found (platform: #{Gem::Platform.local}).
14
+ Reinstall the gem with a Rust toolchain available, or install a platform-specific gem.
15
+ MESSAGE
16
+
17
+ begin
18
+ exec(binary, *arguments)
19
+ rescue SystemCallError => error
20
+ # 実行できない典型は「platform gem は入ったが実行環境と ABI が違う」ケース
21
+ # (musl 環境に glibc ビルドが入るなど)。素の errno だけでは原因が読めない。
22
+ abort <<~MESSAGE
23
+ Sonicop's native executable could not be started (platform: #{Gem::Platform.local}).
24
+ #{binary}
25
+ #{error.class}: #{error.message}
26
+ The installed platform gem probably does not match this system.
27
+ Reinstall from source with: gem install sonicop --platform ruby
28
+ MESSAGE
29
+ end
30
+ end
31
+
32
+ # 環境依存の入力はすべて引数にしてある。既定値は本番の解決経路そのもので、
33
+ # テストからは偽のツリー・偽の spec を渡して候補順を検証する。
34
+ def find_binary(root: gem_root, env: ENV, specification: installed_specification, windows: Gem.win_platform?)
35
+ candidates(root: root, env: env, specification: specification, windows: windows)
36
+ .find { |path| File.file?(path) && File.executable?(path) }
37
+ end
38
+
39
+ # 優先順位は「明示指定 > platform gem 同梱 > ソース gem のビルド成果物 > 開発ツリー」。
40
+ def candidates(root: gem_root, env: ENV, specification: installed_specification, windows: Gem.win_platform?)
41
+ executable = windows ? 'sonicop.exe' : 'sonicop'
42
+ installed_executable = windows ? 'sonicop-bin.exe' : 'sonicop-bin'
43
+
44
+ paths = []
45
+ paths << env['SONICOP_BINARY'] if env['SONICOP_BINARY']
46
+ paths << File.join(root, 'libexec', executable)
47
+ if specification
48
+ paths << File.join(specification.extension_dir, executable)
49
+ paths << File.join(specification.extension_dir, installed_executable)
50
+ paths << File.join(specification.full_gem_path, 'lib', installed_executable)
51
+ end
52
+ paths << File.join(root, 'target', 'release', executable)
53
+ paths << File.join(root, 'target', 'debug', executable)
54
+ paths
55
+ end
56
+
57
+ def gem_root
58
+ File.expand_path('../..', __dir__)
59
+ end
60
+
61
+ def installed_specification
62
+ Gem::Specification.find_by_name('sonicop', Sonicop::VERSION)
63
+ rescue Gem::LoadError
64
+ nil # Running from a source checkout.
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated from Cargo.toml by `rake version:sync`. Do not edit by hand.
4
+ module Sonicop
5
+ VERSION = '26.8.101'
6
+ end
data/lib/sonicop.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'sonicop/version'
4
+ require_relative 'sonicop/runner'
5
+
6
+ module Sonicop
7
+ end
8
+
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012-26 Bozhidar Batsov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Rob Rix
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.