rubocop-infinum 0.0.1
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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +1 -0
- data/.rubocop.yml +45 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +9 -0
- data/README.md +18 -0
- data/Rakefile +8 -0
- data/bin/console +13 -0
- data/bin/setup +8 -0
- data/lib/rubocop-infinum.rb +12 -0
- data/lib/rubocop/cop/infinum/attribute_default_block_value.rb +56 -0
- data/lib/rubocop/cop/infinum_cops.rb +3 -0
- data/lib/rubocop/infinum.rb +9 -0
- data/lib/rubocop/infinum/version.rb +7 -0
- data/rubocop-infinum.gemspec +36 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8880040332319a24731a15c229bf9ec8959c2f3b0a1307be6ff3104ddbf2caeb
|
4
|
+
data.tar.gz: e276673139e2486ab42e3787aac4844543c5fb7516f809f533654e7f9c6ffa89
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f8869b6c02708ed18e174a91a723af17c652badb5f1022b78f2d2485945afa81945216a59940968cd679e855db4abb646adfe3bf21c3d1bee05d5c7e88ca9a0b
|
7
|
+
data.tar.gz: 816242140887f448de62cb9ef450345870780225e7a572a8047b1e05a9c126a949534a578fd659c293a0a0913811f12a011b035db3be7734c7d1243f0672f102
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rails
|
3
|
+
- rubocop-rspec
|
4
|
+
|
5
|
+
Layout/LineLength:
|
6
|
+
Max: 100
|
7
|
+
|
8
|
+
Metrics/BlockLength:
|
9
|
+
Exclude:
|
10
|
+
- 'spec/**/*_spec.rb'
|
11
|
+
|
12
|
+
Style/Documentation:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Style/FrozenStringLiteralComment:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Style/WordArray:
|
19
|
+
EnforcedStyle: brackets
|
20
|
+
|
21
|
+
Style/SymbolArray:
|
22
|
+
EnforcedStyle: brackets
|
23
|
+
|
24
|
+
Style/HashEachMethods:
|
25
|
+
Enabled: true
|
26
|
+
|
27
|
+
Style/HashTransformKeys:
|
28
|
+
Enabled: true
|
29
|
+
|
30
|
+
Style/HashTransformValues:
|
31
|
+
Enabled: true
|
32
|
+
|
33
|
+
Rails:
|
34
|
+
Enabled: true
|
35
|
+
|
36
|
+
RSpec/ExampleLength:
|
37
|
+
Max: 10
|
38
|
+
|
39
|
+
AllCops:
|
40
|
+
TargetRubyVersion: 2.5
|
41
|
+
Exclude:
|
42
|
+
- 'db/schema.rb'
|
43
|
+
- 'db/migrate/*.rb'
|
44
|
+
- 'config/**/*.rb'
|
45
|
+
NewCops: enable
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.0
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Rubocop Infinum
|
2
|
+
|
3
|
+
This gem provides the .RuboCop configuration file alongside some custom cops used at Infinum.
|
4
|
+
|
5
|
+
To use it, you can add this to your `Gemfile` (`group :development`):
|
6
|
+
|
7
|
+
~~~ruby
|
8
|
+
gem 'rubocop-infinum', require: false
|
9
|
+
~~~
|
10
|
+
|
11
|
+
And add to the top of your project's RuboCop configuration file:
|
12
|
+
|
13
|
+
~~~yml
|
14
|
+
inherit_gem:
|
15
|
+
rubocop-infinum: rubocop.yml
|
16
|
+
~~~
|
17
|
+
|
18
|
+
If you dislike some rules, please check [RuboCop's documentation](https://rubocop.readthedocs.io/en/latest/configuration/#inheriting-configuration-from-a-dependency-gem) on inheriting configuration from a gem.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
|
5
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
6
|
+
# with your gem easier. You can also use a different console, if you like.
|
7
|
+
|
8
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
9
|
+
# require "pry"
|
10
|
+
# Pry.start
|
11
|
+
|
12
|
+
require 'irb'
|
13
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# rubocop:disable Naming/FileName
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require 'rubocop'
|
6
|
+
|
7
|
+
require_relative 'rubocop/infinum'
|
8
|
+
require_relative 'rubocop/infinum/version'
|
9
|
+
|
10
|
+
require_relative 'rubocop/cop/infinum_cops'
|
11
|
+
|
12
|
+
# rubocop:enable Naming/FileName
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubocop'
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
module Infinum
|
8
|
+
# This cop looks for `attribute` class methods that don't
|
9
|
+
# specify a `:default` option inside a block.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# # bad
|
13
|
+
# class User < ApplicationRecord
|
14
|
+
# attribute :confirmed_at, :datetime, default: Time.zone.now
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# # good
|
18
|
+
# class User < ActiveRecord::Base
|
19
|
+
# attribute :confirmed_at, :datetime, default: -> { Time.zone.now }
|
20
|
+
# end
|
21
|
+
class AttributeDefaultBlockValue < ::RuboCop::Cop::Cop
|
22
|
+
MSG = 'Pass a block to `:default` option.'
|
23
|
+
|
24
|
+
def_node_search :active_resource_class?, <<~PATTERN
|
25
|
+
(const (const nil? :ActiveResource) :Base)
|
26
|
+
PATTERN
|
27
|
+
|
28
|
+
def_node_matcher :attribute?, '(send nil? :attribute _ _ $hash)'
|
29
|
+
|
30
|
+
def on_send(node)
|
31
|
+
return if active_resource?(node.parent)
|
32
|
+
|
33
|
+
attribute?(node) do |third_arg|
|
34
|
+
default_attribute = default_attribute(third_arg)
|
35
|
+
|
36
|
+
unless [:block, :true, :false].include?(default_attribute.children.last.type) # rubocop:disable Lint/BooleanSymbol
|
37
|
+
add_offense(node, location: default_attribute)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def active_resource?(node)
|
45
|
+
return false if node.nil?
|
46
|
+
|
47
|
+
active_resource_class?(node)
|
48
|
+
end
|
49
|
+
|
50
|
+
def default_attribute(node)
|
51
|
+
node.children.first
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/rubocop/infinum/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'rubocop-infinum'
|
7
|
+
spec.version = RuboCop::Infinum::VERSION
|
8
|
+
spec.authors = ['Marko Ćilimković', 'Stjepan Hađić']
|
9
|
+
spec.email = ['team.backend@infinum.com']
|
10
|
+
|
11
|
+
spec.summary = 'Automatic Infinum code style checking tool.'
|
12
|
+
spec.homepage = 'https://github.com/infinum/rubocop-infinum'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.required_ruby_version = '>= 2.5'
|
16
|
+
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
19
|
+
spec.metadata['source_code_uri'] = 'https://github.com/infinum/rubocop-infinum'
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
24
|
+
f.match(%r{^(test|spec|features)/})
|
25
|
+
end
|
26
|
+
spec.bindir = 'exe'
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
|
30
|
+
spec.add_development_dependency('pry-byebug', '< 4')
|
31
|
+
spec.add_development_dependency('rspec', '~> 3.9')
|
32
|
+
|
33
|
+
spec.add_runtime_dependency('rubocop')
|
34
|
+
spec.add_runtime_dependency('rubocop-rails')
|
35
|
+
spec.add_runtime_dependency('rubocop-rspec')
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubocop-infinum
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marko Ćilimković
|
8
|
+
- Stjepan Hađić
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2020-08-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: pry-byebug
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "<"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '4'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "<"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '4'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rspec
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '3.9'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '3.9'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rubocop
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rubocop-rails
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rubocop-rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
description:
|
85
|
+
email:
|
86
|
+
- team.backend@infinum.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".rubocop.yml"
|
94
|
+
- ".ruby-version"
|
95
|
+
- CHANGELOG.md
|
96
|
+
- Gemfile
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- lib/rubocop-infinum.rb
|
102
|
+
- lib/rubocop/cop/infinum/attribute_default_block_value.rb
|
103
|
+
- lib/rubocop/cop/infinum_cops.rb
|
104
|
+
- lib/rubocop/infinum.rb
|
105
|
+
- lib/rubocop/infinum/version.rb
|
106
|
+
- rubocop-infinum.gemspec
|
107
|
+
homepage: https://github.com/infinum/rubocop-infinum
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata:
|
111
|
+
allowed_push_host: https://rubygems.org
|
112
|
+
homepage_uri: https://github.com/infinum/rubocop-infinum
|
113
|
+
source_code_uri: https://github.com/infinum/rubocop-infinum
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '2.5'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.7.3
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: Automatic Infinum code style checking tool.
|
134
|
+
test_files: []
|