rails-cops 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b1d40596f0dc6a124e29d0c82f55f0ca48de0153c64cc164718ea504fcb22783
4
+ data.tar.gz: ab0d3b8d41383d206f0f9694053b18b328b52d7a34e0aa9aba42da1b9a32da6d
5
+ SHA512:
6
+ metadata.gz: 4ff62a7873f745ceca834c11722ccef1dd058e4b40128527d9fc2e4c2fe63b437066c5aee090ce9a70b316400c69b453d332684511833e1c13ab60208dd8e43e
7
+ data.tar.gz: dbb960fa43c3a965159c1494a35904e09204d022f30b2715559efe2d3681350f32bf0f91a1db98b64a893d5e7e04799a952ea8691f44e56989771befa5e1e96a
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-09-05
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in rails-cops.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,54 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rails-cops (0.1.0)
5
+ activesupport (>= 4.2.0)
6
+ rubocop (>= 1.33.0, < 2.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (7.0.4.2)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 1.6, < 2)
14
+ minitest (>= 5.1)
15
+ tzinfo (~> 2.0)
16
+ ast (2.4.2)
17
+ concurrent-ruby (1.2.2)
18
+ i18n (1.12.0)
19
+ concurrent-ruby (~> 1.0)
20
+ json (2.6.3)
21
+ minitest (5.17.0)
22
+ parallel (1.22.1)
23
+ parser (3.2.1.1)
24
+ ast (~> 2.4.1)
25
+ rainbow (3.1.1)
26
+ rake (13.0.6)
27
+ regexp_parser (2.7.0)
28
+ rexml (3.2.5)
29
+ rubocop (1.48.0)
30
+ json (~> 2.3)
31
+ parallel (~> 1.10)
32
+ parser (>= 3.2.0.0)
33
+ rainbow (>= 2.2.2, < 4.0)
34
+ regexp_parser (>= 1.8, < 3.0)
35
+ rexml (>= 3.2.5, < 4.0)
36
+ rubocop-ast (>= 1.26.0, < 2.0)
37
+ ruby-progressbar (~> 1.7)
38
+ unicode-display_width (>= 2.4.0, < 3.0)
39
+ rubocop-ast (1.27.0)
40
+ parser (>= 3.2.1.0)
41
+ ruby-progressbar (1.13.0)
42
+ tzinfo (2.0.6)
43
+ concurrent-ruby (~> 1.0)
44
+ unicode-display_width (2.4.2)
45
+
46
+ PLATFORMS
47
+ arm64-darwin-22
48
+
49
+ DEPENDENCIES
50
+ rails-cops!
51
+ rake (~> 13.0)
52
+
53
+ BUNDLED WITH
54
+ 2.4.7
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # Rails::Cops
2
+
3
+ These are custom cops for Lixibox Rails project.
4
+
5
+ ## Installation
6
+
7
+ Install the gem and add to the application's Gemfile by executing:
8
+
9
+ $ bundle add rails-cops
10
+
11
+ If bundler is not being used to manage dependencies, install the gem by executing:
12
+
13
+ $ gem install rails-cops
14
+
15
+ ## Usage
16
+
17
+ You need to tell RuboCop to load the Rails extension. There are three
18
+ ways to do this:
19
+
20
+ ### RuboCop configuration file
21
+
22
+ Put this into your `.rubocop.yml`.
23
+
24
+ ```yaml
25
+ require: rails-cops
26
+ ```
27
+
28
+ Alternatively, use the following array notation when specifying multiple extensions.
29
+
30
+ ```yaml
31
+ require:
32
+ - rubocop-other-extension
33
+ - rails-cops
34
+ ```
35
+
36
+ Now you can run `rubocop` and it will automatically load the RuboCop Rails
37
+ cops together with the standard cops.
38
+
39
+ ### Command line
40
+
41
+ ```sh
42
+ $ rubocop --require rails-cops
43
+ ```
44
+
45
+ ## Development
46
+
47
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
48
+
49
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
50
+
51
+ ## Contributing
52
+
53
+ Bug reports and pull requests are welcome on GitHub at https://github.com/lixibox/rails-cops.
54
+
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,27 @@
1
+ # Common configuration.
2
+
3
+ inherit_mode:
4
+ merge:
5
+ - Exclude
6
+
7
+ AllCops:
8
+ Exclude:
9
+ - app/assets/**/*
10
+ - bin/*
11
+ # Exclude db/schema.rb and db/[CONFIGURATION_NAMESPACE]_schema.rb by default.
12
+ # See: https://guides.rubyonrails.org/active_record_multiple_databases.html#setting-up-your-application
13
+ - db/*schema.rb
14
+ - log/**/*
15
+ - public/**/*
16
+ - storage/**/*
17
+ # Enable checking Active Support extensions.
18
+ # See: https://docs.rubocop.org/rubocop/configuration.html#enable-checking-active-support-extensions
19
+ ActiveSupportExtensionsEnabled: true
20
+ # What version of Rails is the inspected code using? If a value is specified
21
+ # for TargetRailsVersion then it is used. Acceptable values are specified
22
+ # as a float (i.e. 5.1); the patch version of Rails should not be included.
23
+ # If TargetRailsVersion is not set, RuboCop will parse the Gemfile.lock or
24
+ # gems.locked file to find the version of Rails that has been bound to the
25
+ # application. If neither of those files exist, RuboCop will use Rails 5.0
26
+ # as the default.
27
+ TargetRailsVersion: ~
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rails
4
+ module Cops
5
+ # This is for custom rubocop rule
6
+ class ModelCustomValidationMethodName < ::RuboCop::Cop::Base
7
+ MSG = 'You are using model validation method name without _validation, please add suffix _validation to the method name'.freeze
8
+
9
+ def_node_matcher :custom_validation, <<-PATTERN
10
+ (send nil? :validate
11
+ (sym $_) $...)
12
+ PATTERN
13
+
14
+ # event handler
15
+ def on_send(node)
16
+ custom_validation(node) do |method_name, _args|
17
+ method_node = node.children[2]
18
+ add_offense(method_node, message: MSG) unless method_name.end_with?('_validation')
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rails
4
+ module Cops
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
data/lib/rails/cops.rb ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubocop'
4
+ require_relative 'cops/version'
5
+ require_relative 'cops/model_custom_validation_method_name'
6
+
7
+ module Rails
8
+ module Cops
9
+ class Error < StandardError; end
10
+ # Your code goes here...
11
+ end
12
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/rails/cops/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rails-cops"
7
+ spec.version = Rails::Cops::VERSION
8
+ spec.authors = ["Lixibox"]
9
+ spec.email = ["tech@lixibox.com"]
10
+
11
+ spec.summary = "Custom cops for Lixibox Rails project."
12
+ spec.description = "Custom cops for Lixibox Rails project."
13
+ spec.homepage = "https://github.com/lixibox/rails-cops"
14
+ spec.required_ruby_version = ">= 2.6.0"
15
+
16
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/lixibox/rails-cops"
20
+ spec.metadata["changelog_uri"] = "https://github.com/lixibox/rails-cops"
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(__dir__) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (File.expand_path(f) == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ # Uncomment to register a new dependency of your gem
34
+ # spec.add_dependency "example-gem", "~> 1.0"
35
+ spec.add_runtime_dependency 'activesupport', '>= 4.2.0'
36
+ # Rack::Utils::SYMBOL_TO_STATUS_CODE, which is used by HttpStatus cop, was
37
+ # introduced in rack 1.1
38
+ spec.add_runtime_dependency 'rubocop', '>= 1.33.0', '< 2.0'
39
+ # For more information and examples about making a new gem, check out our
40
+ # guide at: https://bundler.io/guides/creating_gem.html
41
+ end
@@ -0,0 +1,6 @@
1
+ module Rails
2
+ module Cops
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-cops
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Lixibox
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-09-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.33.0
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '2.0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.33.0
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
47
+ description: Custom cops for Lixibox Rails project.
48
+ email:
49
+ - tech@lixibox.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - CHANGELOG.md
55
+ - Gemfile
56
+ - Gemfile.lock
57
+ - README.md
58
+ - Rakefile
59
+ - config/default.yml
60
+ - lib/rails/cops.rb
61
+ - lib/rails/cops/model_custom_validation_method_name.rb
62
+ - lib/rails/cops/version.rb
63
+ - rails-cops.gemspec
64
+ - sig/rails/cops.rbs
65
+ homepage: https://github.com/lixibox/rails-cops
66
+ licenses: []
67
+ metadata:
68
+ allowed_push_host: https://rubygems.org
69
+ homepage_uri: https://github.com/lixibox/rails-cops
70
+ source_code_uri: https://github.com/lixibox/rails-cops
71
+ changelog_uri: https://github.com/lixibox/rails-cops
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 2.6.0
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubygems_version: 3.2.3
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Custom cops for Lixibox Rails project.
91
+ test_files: []