rubocop-yast 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e63535b7478f815aac43bfe5da02c56006678682
4
+ data.tar.gz: 11b6d89cf12d0db91b630f05a7d9baaff6e5b020
5
+ SHA512:
6
+ metadata.gz: 1ef0b777751ab6bc35a86a28be492e463d2a247f8f04ce349ec5c8a352f084077e96281dc97477781e337765ecebf11e4cb4379c6d4be53a29f2b99474a89121
7
+ data.tar.gz: b05076a39ab723d61b0579be49cb973236ebfbca00628bf4a18a9bd48a4c5432064d2d87537a45a1a5c4ff1ca5329d77dfc9cb07cc405e4328fe80639ddaed89
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ group :test do
8
+ gem "coveralls", require: false if ENV["TRAVIS"]
9
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Ladislav Slezák
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.
22
+
@@ -0,0 +1,9 @@
1
+ rubocop-yast
2
+ ============
3
+
4
+ [![Travis Build](https://travis-ci.org/lslezak/rubocop-yast.svg?branch=master)](https://travis-ci.org/lslezak/rubocop-yast)
5
+ [![Coverage Status](https://img.shields.io/coveralls/lslezak/rubocop-yast.svg)](https://coveralls.io/r/lslezak/rubocop-yast?branch=master)
6
+ [![Code Climate](https://codeclimate.com/github/lslezak/rubocop-yast/badges/gpa.svg)](https://codeclimate.com/github/lslezak/rubocop-yast)
7
+ [![Inline docs](http://inch-ci.org/github/lslezak/rubocop-yast.svg?branch=master)](http://inch-ci.org/github/lslezak/rubocop-yast)
8
+
9
+
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ require "bundler"
4
+ require "bundler/gem_tasks"
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+
13
+ require "rspec/core/rake_task"
14
+ RSpec::Core::RakeTask.new(:spec)
15
+
16
+ require "rubocop/rake_task"
17
+ RuboCop::RakeTask.new(:rubocop)
18
+
19
+ task default: [:spec, :rubocop]
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+
3
+ require "rubocop"
4
+
5
+ require_relative "rubocop/yast/version"
6
+ require_relative "rubocop/cop/yast/builtins"
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Yast
6
+ # This cop checks for using obsoleted Yast Builtins calls
7
+ class Builtins < Cop
8
+ include AST::Sexp
9
+
10
+ MSG = "Builtin call `%s` is obsolete, use native Ruby function instead."
11
+
12
+ # white list of allowed Builtins calls
13
+ ALLOWED_FUNCTIONS = [
14
+ # locale dependent sorting in not available in Ruby stdlib
15
+ :lsort
16
+ ]
17
+
18
+ BUILTINS_NODES = [
19
+ s(:const, nil, :Builtins),
20
+ s(:const, s(:cbase), :Builtins)
21
+ ]
22
+
23
+ def on_send(node)
24
+ receiver, method_name, *_args = *node
25
+
26
+ return if !BUILTINS_NODES.include?(receiver) ||
27
+ ALLOWED_FUNCTIONS.include?(method_name)
28
+
29
+ add_offense(node, :selector, format(MSG, method_name))
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ module RuboCop
4
+ # Yast plugin settings
5
+ module Yast
6
+ VERSION = "0.0.1"
7
+ end
8
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
4
+ require "rubocop/yast/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rubocop-yast"
8
+ spec.summary = "Specific YaST Rubocop checks"
9
+ spec.description = "A plugin for the RuboCop code style checker\n" \
10
+ "This Rubocop plugin checks for YaST specific issues."
11
+ spec.homepage = "http://github.com/yast/rubocop-yast"
12
+ spec.authors = ["Ladislav Slezák"]
13
+ spec.email = ["lslezak@suse.cz"]
14
+ spec.licenses = ["MIT"]
15
+
16
+ spec.version = RuboCop::Yast::VERSION
17
+ spec.platform = Gem::Platform::RUBY
18
+ spec.required_ruby_version = ">= 1.9.3"
19
+
20
+ spec.require_paths = ["lib"]
21
+ spec.files = Dir[
22
+ "{lib,spec}/**/*",
23
+ "*.md",
24
+ "*.gemspec",
25
+ "Gemfile",
26
+ "Rakefile"
27
+ ]
28
+ spec.test_files = spec.files.grep(/^spec\//)
29
+ spec.extra_rdoc_files = ["LICENSE", "README.md"]
30
+
31
+ spec.add_development_dependency("rubocop", "~> 0.27")
32
+ spec.add_development_dependency("rake")
33
+ spec.add_development_dependency("rspec", "~> 2.14.1")
34
+ spec.add_development_dependency("simplecov")
35
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ require "spec_helper"
4
+
5
+ describe RuboCop::Cop::Yast::Builtins do
6
+ subject(:cop) { described_class.new }
7
+
8
+ it "reports Builtins.* call" do
9
+ inspect_source(cop, ['Builtins.y2milestone("foo")'])
10
+
11
+ expect(cop.offenses).to have(1).item
12
+ expect(cop.offenses.first.line).to eq(1)
13
+ expect(cop.messages).to eq(["Builtin call `y2milestone` is obsolete, " \
14
+ "use native Ruby function instead."])
15
+ end
16
+
17
+ it "ignores lsort builtin" do
18
+ inspect_source(cop, ['Builtins.lsort(["foo"])'])
19
+
20
+ expect(cop.offenses).to be_empty
21
+ end
22
+
23
+ end
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+ if ENV["COVERAGE"]
4
+ require "simplecov"
5
+
6
+ # use coveralls for on-line code coverage reporting at Travis CI
7
+ if ENV["TRAVIS"]
8
+ require "coveralls"
9
+
10
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
11
+ SimpleCov::Formatter::HTMLFormatter,
12
+ Coveralls::SimpleCov::Formatter
13
+ ]
14
+ end
15
+
16
+ SimpleCov.minimum_coverage 95
17
+
18
+ SimpleCov.start
19
+ end
20
+
21
+ # allow only the new "expect" RSpec syntax
22
+ RSpec.configure do |config|
23
+ config.treat_symbols_as_metadata_keys_with_true_values = true
24
+
25
+ config.expect_with :rspec do |c|
26
+ c.syntax = :expect
27
+ end
28
+
29
+ config.mock_with :rspec do |c|
30
+ c.syntax = :expect
31
+ end
32
+ end
33
+
34
+ # As much as possible, we try to reuse RuboCop's spec environment.
35
+ require File.join(
36
+ Gem::Specification.find_by_name("rubocop").gem_dir, "spec", "spec_helper.rb"
37
+ )
38
+
39
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
40
+
41
+ require "rubocop-yast"
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubocop-yast
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ladislav Slezák
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-02 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.27'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.27'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.14.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.14.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: |-
70
+ A plugin for the RuboCop code style checker
71
+ This Rubocop plugin checks for YaST specific issues.
72
+ email:
73
+ - lslezak@suse.cz
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files:
77
+ - LICENSE
78
+ - README.md
79
+ files:
80
+ - Gemfile
81
+ - LICENSE
82
+ - README.md
83
+ - Rakefile
84
+ - lib/rubocop-yast.rb
85
+ - lib/rubocop/cop/yast/builtins.rb
86
+ - lib/rubocop/yast/version.rb
87
+ - rubocop-yast.gemspec
88
+ - spec/builtins_spec.rb
89
+ - spec/spec_helper.rb
90
+ homepage: http://github.com/yast/rubocop-yast
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 1.9.3
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.2.2
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Specific YaST Rubocop checks
114
+ test_files:
115
+ - spec/builtins_spec.rb
116
+ - spec/spec_helper.rb