polleverywhere-cops 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/LICENSE +21 -0
- data/README.md +3 -0
- data/lib/polleverywhere-cops.rb +5 -0
- data/lib/rubocop/cop/polleverywhere/nullable_boolean.rb +40 -0
- data/lib/rubocop/polleverywhere/version.rb +9 -0
- data/polleverywhere-cops.gemspec +19 -0
- metadata +68 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 89c21da7018763638112ed372c643da8c6d47f9c
|
4
|
+
data.tar.gz: 81e2bb70ee9313c7253ecf1b312327dbedfa323b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dd13214973ef2ca7b2351861881acee84d0de4b2a9f48c59a989b005904827d2ce22027076e2162b6a2633d7ee254b8bd853bd1abbccc31fb50e12a0f2972501
|
7
|
+
data.tar.gz: ea2c03d68045b23aeae81d9b528ea7cb79ebfb107095b0107a7aece3ae956fa68c33efb63d90a70a1e324c54156bf338eea9f8e8f91d66da1de55753f68e181e
|
data/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Environment normalization:
|
13
|
+
/.bundle/
|
14
|
+
/vendor/bundle
|
15
|
+
/lib/bundler/man/
|
16
|
+
|
17
|
+
# for a library or gem, you might want to ignore these files since the code is
|
18
|
+
# intended to run in multiple environments; otherwise, check them in:
|
19
|
+
Gemfile.lock
|
20
|
+
.ruby-version
|
21
|
+
.ruby-gemset
|
22
|
+
|
23
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
24
|
+
.rvmrc
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Poll Everywhere
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module PollEverywhere
|
6
|
+
class NullableBoolean < Cop
|
7
|
+
MSG = "Boolean columns cannot be nullable. (https://playbook.polleverywhere.com/conventions/ruby/#migrations)".freeze
|
8
|
+
|
9
|
+
def on_send(node)
|
10
|
+
if adding_boolean?(node) && nullable?(node)
|
11
|
+
add_offense(node, :expression, MSG)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def relevant_file?(file)
|
16
|
+
super && file =~ %r(/db/migrate/.+\.rb\z)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def adding_boolean?(node)
|
22
|
+
code_match = node.method_name == :boolean ||
|
23
|
+
node.source =~ /(add|change)_column.+boolean/mi
|
24
|
+
code_match && !in_excluded_method?(node)
|
25
|
+
end
|
26
|
+
|
27
|
+
def in_excluded_method?(node)
|
28
|
+
node.each_ancestor(:def).any? do |parent_node|
|
29
|
+
method_name, _args, _body = *parent_node
|
30
|
+
method_name == :down
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def nullable?(node)
|
35
|
+
node.source !~ /(null:\s*false)|(:null\s*=>\s*false)|(NOT\s+NULL)/i
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/rubocop/polleverywhere/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "polleverywhere-cops"
|
6
|
+
gem.version = RuboCop::PollEverywhere::Version::STRING
|
7
|
+
gem.license = "MIT"
|
8
|
+
gem.authors = ["Poll Everywhere"]
|
9
|
+
gem.email = ["geeks@polleverywhere.com"]
|
10
|
+
gem.homepage = "https://www.polleverywhere.com"
|
11
|
+
gem.summary = "Custom RuboCop cops for Poll Everywhere"
|
12
|
+
gem.description = "Custom RuboCop cops for Poll Everywhere"
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.extra_rdoc_files = ["README.md"]
|
16
|
+
gem.rdoc_options = ["--main", "README.md"]
|
17
|
+
|
18
|
+
gem.add_runtime_dependency "rubocop", ">= 0.48.1"
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: polleverywhere-cops
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Poll Everywhere
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubocop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.48.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.48.1
|
27
|
+
description: Custom RuboCop cops for Poll Everywhere
|
28
|
+
email:
|
29
|
+
- geeks@polleverywhere.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files:
|
33
|
+
- README.md
|
34
|
+
files:
|
35
|
+
- ".gitignore"
|
36
|
+
- LICENSE
|
37
|
+
- README.md
|
38
|
+
- lib/polleverywhere-cops.rb
|
39
|
+
- lib/rubocop/cop/polleverywhere/nullable_boolean.rb
|
40
|
+
- lib/rubocop/polleverywhere/version.rb
|
41
|
+
- polleverywhere-cops.gemspec
|
42
|
+
homepage: https://www.polleverywhere.com
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata: {}
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options:
|
48
|
+
- "--main"
|
49
|
+
- README.md
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 2.6.13
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: Custom RuboCop cops for Poll Everywhere
|
68
|
+
test_files: []
|