rubocop-exception_call 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3da565cfe98f0feb5194e680986b249099ea8bd1
4
+ data.tar.gz: df1d8d9ff1ba3acd46b957265535239b034a5d95
5
+ SHA512:
6
+ metadata.gz: e1b6441410785c3fcba437a2c7872d153b0eb1c26c28e39f4ef2d3daea95a72da27821cbc8e0ef89d696083b1afe3298231e4413ce36b79220cd47a4a615a1e2
7
+ data.tar.gz: 31e5de98498d41b29c7e7724835e7ed0b224fca6e3321a2556cd97b5cc1531f57abfd3785717c3a212aafaca63a957ffb425bbc20c82987fa2f9f6df1e19bbd6
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "vendor/rubocop"]
2
+ path = vendor/rubocop
3
+ url = git@github.com:bbatsov/rubocop.git
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rubocop-exception_call.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Rubocop::ExceptionCall
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rubocop/exception_call`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'rubocop-exception_call'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install rubocop-exception_call
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rubocop-exception_call.
36
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rubocop/exception_call"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ Lint/ExceptionCall:
2
+ Description: '例外送出の際のカンマ忘れを指摘します'
3
+ Enabled: true
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ module RuboCop
5
+ module Cop
6
+ module Lint
7
+ class ExceptionCall < Cop
8
+ MSG = 'カンマ(,)を忘れていませんか?'.freeze
9
+
10
+ def on_send(node)
11
+ receiver, method_name, *args = *node
12
+ return unless [:raise, :fail].include?(method_name)
13
+ return unless check_receiver(receiver)
14
+ return unless check_args(args)
15
+
16
+ add_offense(node, loc(args))
17
+ end
18
+
19
+ def autocorrect(node)
20
+ _receiver, _method_name, *args = *node
21
+
22
+ lambda do |corrector|
23
+ corrector.insert_before(loc(args), ',')
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def check_receiver(receiver)
30
+ return true unless receiver
31
+ return true if receiver.const_type? && receiver.const_name == 'Kernel'
32
+ return false
33
+ end
34
+
35
+ def check_args(args)
36
+ return false unless args.size == 1
37
+
38
+ arg = args.first
39
+ return false unless arg.send_type?
40
+ _receiver, method_name, _args = *arg
41
+ return method_name =~ /^[A-Z]/
42
+ end
43
+
44
+ def loc(args)
45
+ arg = args.first
46
+ _receiver, _method_name, inner_args = *arg
47
+ end_pos = inner_args.loc.begin.begin_pos
48
+ begin_pos = arg.loc.selector.end_pos
49
+ Parser::Source::Range.new(arg.loc.expression.source_buffer, begin_pos, end_pos)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,8 @@
1
+ require 'rubocop'
2
+ require "rubocop/exception_call/version"
3
+ require 'rubocop/exception_call/inject'
4
+
5
+ RuboCop::DefinitionValidator::Inject.defaults!
6
+
7
+ # cops
8
+ require 'rubocop/cop/lint/exception_call'
@@ -0,0 +1,23 @@
1
+ # This file is copied from rubocop-rspec
2
+ require 'yaml'
3
+
4
+ module RuboCop
5
+ module DefinitionValidator
6
+ # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
7
+ # bit of our configuration.
8
+ module Inject
9
+ DEFAULT_FILE = File.expand_path(
10
+ '../../../../config/default.yml', __FILE__
11
+ )
12
+
13
+ def self.defaults!
14
+ path = File.absolute_path(DEFAULT_FILE)
15
+ hash = ConfigLoader.send(:load_yaml_configuration, path)
16
+ config = Config.new(hash, path)
17
+ puts "configuration from #{DEFAULT_FILE}" if ConfigLoader.debug?
18
+ config = ConfigLoader.merge_with_default(config, path)
19
+ ConfigLoader.instance_variable_set(:@default_configuration, config)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ module Rubocop
2
+ module ExceptionCall
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rubocop/exception_call/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rubocop-exception_call"
8
+ spec.version = Rubocop::ExceptionCall::VERSION
9
+ spec.authors = ["Masataka Kuwabara"]
10
+ spec.email = ["p.ck.t22@gmail.com"]
11
+
12
+ spec.summary = %q{例外送出の際のカンマ忘れを指摘するRubocopプラグイン}
13
+ spec.description = %q{例外送出の際のカンマ忘れを指摘するRubocopプラグイン}
14
+ spec.homepage = "https://github.com/actcat/rubocop-exception_call"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "rubocop", "~> 0.40.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.11"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+
26
+ spec.add_development_dependency "rspec", "~> 3.4.0"
27
+ spec.add_development_dependency 'pry', '~> 0.10.3'
28
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubocop-exception_call
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Masataka Kuwabara
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-07 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.40.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.40.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.4.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.4.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.10.3
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.10.3
83
+ description: 例外送出の際のカンマ忘れを指摘するRubocopプラグイン
84
+ email:
85
+ - p.ck.t22@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".gitmodules"
92
+ - ".rspec"
93
+ - Gemfile
94
+ - README.md
95
+ - Rakefile
96
+ - bin/console
97
+ - bin/setup
98
+ - config/default.yml
99
+ - lib/rubocop/cop/lint/exception_call.rb
100
+ - lib/rubocop/exception_call.rb
101
+ - lib/rubocop/exception_call/inject.rb
102
+ - lib/rubocop/exception_call/version.rb
103
+ - rubocop-exception_call.gemspec
104
+ homepage: https://github.com/actcat/rubocop-exception_call
105
+ licenses: []
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.5.1
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: 例外送出の際のカンマ忘れを指摘するRubocopプラグイン
127
+ test_files: []