codeclimate-yaml 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cc/yaml/nodes/language.rb +32 -0
- data/lib/cc/yaml/nodes/language_list.rb +9 -0
- data/lib/cc/yaml/nodes/mapping.rb +33 -10
- data/lib/cc/yaml/nodes/root.rb +1 -0
- data/lib/cc/yaml/nodes.rb +2 -0
- data/lib/cc/yaml/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09ba5979113592bfe69c17ea1ea515883bf8b236
|
4
|
+
data.tar.gz: b8d0034a571105f3e3f29807fc9edce39e459c8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1aad8e2a33fa800765cd2f1997524dbb4604911b454695410ae0b02e3fad04a3f24046301fc568bcb982e029b231cb074d6d7f2ad28092c22286ebc889e7cdd
|
7
|
+
data.tar.gz: ebb9b13db51c9ed988e66c009dd31ee4d08cff6d18c56bb7b4936e66ab5bba2d2305e97479cdbcecab53b257ccaebb6f798eca7bc8b8520a6cfccd527adf633c
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module CC
|
2
|
+
module Yaml
|
3
|
+
module Nodes
|
4
|
+
class Language < Scalar
|
5
|
+
LANGUAGES = %w[Ruby JavaScript Python PHP].freeze
|
6
|
+
|
7
|
+
def valid?
|
8
|
+
LANGUAGES.include?(name)
|
9
|
+
end
|
10
|
+
|
11
|
+
def name
|
12
|
+
to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
def appears_to_be_mispelled_version_of?
|
16
|
+
if !valid? && downcased_language_map.has_key?(name.downcase)
|
17
|
+
downcased_language_map[self]
|
18
|
+
else
|
19
|
+
false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def downcased_language_map
|
24
|
+
@downcased_language_map ||=
|
25
|
+
LANGUAGES.each_with_object({}) do |language, obj|
|
26
|
+
obj[language.downcase] = language
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module CC::Yaml
|
2
2
|
module Nodes
|
3
3
|
class Mapping < Node
|
4
|
+
INCOMPATIBLE_KEYS_WARNING = "Analysis settings for Languages and Engines are both valid but mutually exclusive. Note: command line analysis requires an Engines configuration.".freeze
|
5
|
+
|
4
6
|
def self.mapping
|
5
7
|
@mapping ||= superclass.respond_to?(:mapping) ? superclass.mapping.dup : {}
|
6
8
|
end
|
@@ -65,17 +67,12 @@ module CC::Yaml
|
|
65
67
|
def set_warnings(key)
|
66
68
|
if subnode_for(key)
|
67
69
|
check_duplicates(key)
|
68
|
-
|
69
|
-
warning("analysis by language not available via CLI. Use engines configuration instead.")
|
70
|
+
check_incompatibility(key)
|
70
71
|
else
|
71
72
|
warning("unexpected key %p, dropping", key)
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
75
|
-
def check_duplicates(key)
|
76
|
-
warning("has multiple %p entries, keeping last entry", key) if self[key]
|
77
|
-
end
|
78
|
-
|
79
76
|
def []=(key, value)
|
80
77
|
if mapped_key = mapped_key(key)
|
81
78
|
unless value.is_a? Node
|
@@ -178,11 +175,37 @@ module CC::Yaml
|
|
178
175
|
|
179
176
|
protected
|
180
177
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
178
|
+
def dup_values
|
179
|
+
duped_mapping = @mapping.map { |key, value| [key.dup, value.dup] }
|
180
|
+
@mapping = Hash[duped_mapping]
|
181
|
+
self
|
182
|
+
end
|
183
|
+
|
184
|
+
def check_duplicates(key)
|
185
|
+
warning("has multiple %p entries, keeping last entry", key) if self[key]
|
186
|
+
end
|
187
|
+
|
188
|
+
def check_incompatibility(key)
|
189
|
+
if creates_incompatibility?(key)
|
190
|
+
warning(incompatibility_message(key), key)
|
185
191
|
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def incompatibility_message(key)
|
195
|
+
"#{extant_engines_or_languages_key} key already found, dropping key: #{key}. #{INCOMPATIBLE_KEYS_WARNING}"
|
196
|
+
end
|
197
|
+
|
198
|
+
def extant_engines_or_languages_key
|
199
|
+
if self["engines"]
|
200
|
+
"engines"
|
201
|
+
elsif self["languages"]
|
202
|
+
"languages"
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def creates_incompatibility?(key)
|
207
|
+
(key == "engines" && self["languages"]) || (key == "languages" && self["engines"])
|
208
|
+
end
|
186
209
|
end
|
187
210
|
end
|
188
211
|
end
|
data/lib/cc/yaml/nodes/root.rb
CHANGED
data/lib/cc/yaml/nodes.rb
CHANGED
@@ -5,6 +5,8 @@ module CC
|
|
5
5
|
autoload :EngineList, "cc/yaml/nodes/engine_list"
|
6
6
|
autoload :Glob, "cc/yaml/nodes/glob"
|
7
7
|
autoload :GlobList, "cc/yaml/nodes/glob_list"
|
8
|
+
autoload :Language, "cc/yaml/nodes/language"
|
9
|
+
autoload :LanguageList, "cc/yaml/nodes/language_list"
|
8
10
|
autoload :Mapping, "cc/yaml/nodes/mapping"
|
9
11
|
autoload :Node, "cc/yaml/nodes/node"
|
10
12
|
autoload :OpenMapping, "cc/yaml/nodes/open_mapping"
|
data/lib/cc/yaml/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeclimate-yaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code Climate
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: secure_string
|
@@ -50,6 +50,8 @@ files:
|
|
50
50
|
- lib/cc/yaml/nodes/engine_list.rb
|
51
51
|
- lib/cc/yaml/nodes/glob.rb
|
52
52
|
- lib/cc/yaml/nodes/glob_list.rb
|
53
|
+
- lib/cc/yaml/nodes/language.rb
|
54
|
+
- lib/cc/yaml/nodes/language_list.rb
|
53
55
|
- lib/cc/yaml/nodes/mapping.rb
|
54
56
|
- lib/cc/yaml/nodes/node.rb
|
55
57
|
- lib/cc/yaml/nodes/open_mapping.rb
|