codeclimate 0.34.1 → 0.35.0
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 +4 -4
- data/lib/cc/analyzer.rb +1 -11
- data/lib/cc/analyzer/issue_validations.rb +24 -0
- data/lib/cc/analyzer/issue_validations/category_validation.rb +32 -0
- data/lib/cc/analyzer/issue_validations/check_name_presence_validation.rb +15 -0
- data/lib/cc/analyzer/issue_validations/content_validation.rb +25 -0
- data/lib/cc/analyzer/issue_validations/description_presence_validation.rb +15 -0
- data/lib/cc/analyzer/issue_validations/location_format_validation.rb +45 -0
- data/lib/cc/analyzer/issue_validations/other_locations_format_validation.rb +35 -0
- data/lib/cc/analyzer/issue_validations/path_existence_validation.rb +21 -0
- data/lib/cc/analyzer/issue_validations/path_is_file_validation.rb +21 -0
- data/lib/cc/analyzer/issue_validations/path_presence_validation.rb +21 -0
- data/lib/cc/analyzer/issue_validations/relative_path_validation.rb +32 -0
- data/lib/cc/analyzer/issue_validations/type_validation.rb +21 -0
- data/lib/cc/analyzer/issue_validations/validation.rb +23 -0
- data/lib/cc/analyzer/issue_validator.rb +1 -12
- metadata +15 -13
- data/lib/cc/analyzer/issue_category_validation.rb +0 -30
- data/lib/cc/analyzer/issue_check_name_presence_validation.rb +0 -13
- data/lib/cc/analyzer/issue_description_presence_validation.rb +0 -13
- data/lib/cc/analyzer/issue_location_format_validation.rb +0 -43
- data/lib/cc/analyzer/issue_other_locations_format_validation.rb +0 -33
- data/lib/cc/analyzer/issue_path_existence_validation.rb +0 -19
- data/lib/cc/analyzer/issue_path_is_file_validation.rb +0 -19
- data/lib/cc/analyzer/issue_path_presence_validation.rb +0 -19
- data/lib/cc/analyzer/issue_relative_path_validation.rb +0 -30
- data/lib/cc/analyzer/issue_type_validation.rb +0 -19
- data/lib/cc/analyzer/validation.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fc6f49738750affec64ab80ccf8307efec1b9d2
|
4
|
+
data.tar.gz: f1f7e789e916727190cc0059761f50640a2b955f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56e5a24c670d7ea80026c73e21ebc7afb4518760a3951bb3256b5eeb3265ced74d24f0323421849d26640355bbf8ad7859dca1fc936f6ea2caf7140aba0a96ca
|
7
|
+
data.tar.gz: cce1f4745d9b8a85e556ba66cdefef80c1fca52abcb735c61b194866359de988e77276c63a9cb544fd7fc000e191f97c82597a53836ec6229f9cff37e41241bd
|
data/lib/cc/analyzer.rb
CHANGED
@@ -15,17 +15,8 @@ module CC
|
|
15
15
|
autoload :Filesystem, "cc/analyzer/filesystem"
|
16
16
|
autoload :Formatters, "cc/analyzer/formatters"
|
17
17
|
autoload :Issue, "cc/analyzer/issue"
|
18
|
-
autoload :IssueCategoryValidation, "cc/analyzer/issue_category_validation"
|
19
|
-
autoload :IssueCheckNamePresenceValidation, "cc/analyzer/issue_check_name_presence_validation"
|
20
|
-
autoload :IssueDescriptionPresenceValidation, "cc/analyzer/issue_description_presence_validation"
|
21
|
-
autoload :IssueLocationFormatValidation, "cc/analyzer/issue_location_format_validation"
|
22
|
-
autoload :IssueOtherLocationsFormatValidation, "cc/analyzer/issue_other_locations_format_validation"
|
23
|
-
autoload :IssuePathExistenceValidation, "cc/analyzer/issue_path_existence_validation"
|
24
|
-
autoload :IssuePathIsFileValidation, "cc/analyzer/issue_path_is_file_validation"
|
25
|
-
autoload :IssuePathPresenceValidation, "cc/analyzer/issue_path_presence_validation"
|
26
|
-
autoload :IssueRelativePathValidation, "cc/analyzer/issue_relative_path_validation"
|
27
18
|
autoload :IssueSorter, "cc/analyzer/issue_sorter"
|
28
|
-
autoload :
|
19
|
+
autoload :IssueValidations, "cc/analyzer/issue_validations"
|
29
20
|
autoload :IssueValidator, "cc/analyzer/issue_validator"
|
30
21
|
autoload :LocationDescription, "cc/analyzer/location_description"
|
31
22
|
autoload :LoggingContainerListener, "cc/analyzer/logging_container_listener"
|
@@ -35,7 +26,6 @@ module CC
|
|
35
26
|
autoload :SourceExtractor, "cc/analyzer/source_extractor"
|
36
27
|
autoload :SourceFingerprint, "cc/analyzer/source_fingerprint"
|
37
28
|
autoload :StatsdContainerListener, "cc/analyzer/statsd_container_listener"
|
38
|
-
autoload :Validation, "cc/analyzer/validation"
|
39
29
|
|
40
30
|
class DummyStatsd
|
41
31
|
def method_missing(*)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module CC
|
2
|
+
module Analyzer
|
3
|
+
module IssueValidations
|
4
|
+
autoload :CategoryValidation, "cc/analyzer/issue_validations/category_validation"
|
5
|
+
autoload :CheckNamePresenceValidation, "cc/analyzer/issue_validations/check_name_presence_validation"
|
6
|
+
autoload :ContentValidation, "cc/analyzer/issue_validations/content_validation"
|
7
|
+
autoload :DescriptionPresenceValidation, "cc/analyzer/issue_validations/description_presence_validation"
|
8
|
+
autoload :LocationFormatValidation, "cc/analyzer/issue_validations/location_format_validation"
|
9
|
+
autoload :OtherLocationsFormatValidation, "cc/analyzer/issue_validations/other_locations_format_validation"
|
10
|
+
autoload :PathExistenceValidation, "cc/analyzer/issue_validations/path_existence_validation"
|
11
|
+
autoload :PathIsFileValidation, "cc/analyzer/issue_validations/path_is_file_validation"
|
12
|
+
autoload :PathPresenceValidation, "cc/analyzer/issue_validations/path_presence_validation"
|
13
|
+
autoload :RelativePathValidation, "cc/analyzer/issue_validations/relative_path_validation"
|
14
|
+
autoload :TypeValidation, "cc/analyzer/issue_validations/type_validation"
|
15
|
+
autoload :Validation, "cc/analyzer/issue_validations/validation"
|
16
|
+
|
17
|
+
def self.validations
|
18
|
+
constants.sort.map(&method(:const_get)).select do |klass|
|
19
|
+
klass.is_a?(Class) && klass.superclass == Validation
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module CC
|
2
|
+
module Analyzer
|
3
|
+
module IssueValidations
|
4
|
+
class CategoryValidation < Validation
|
5
|
+
CATEGORIES = [
|
6
|
+
"Bug Risk".freeze,
|
7
|
+
"Clarity".freeze,
|
8
|
+
"Compatibility".freeze,
|
9
|
+
"Complexity".freeze,
|
10
|
+
"Duplication".freeze,
|
11
|
+
"Performance".freeze,
|
12
|
+
"Security".freeze,
|
13
|
+
"Style".freeze,
|
14
|
+
].freeze
|
15
|
+
|
16
|
+
def valid?
|
17
|
+
object["categories"].present? && no_invalid_categories?
|
18
|
+
end
|
19
|
+
|
20
|
+
def message
|
21
|
+
"Category must be at least one of #{CATEGORIES.join(", ")}"
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def no_invalid_categories?
|
27
|
+
(CATEGORIES | object["categories"]) == CATEGORIES
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module CC
|
2
|
+
module Analyzer
|
3
|
+
module IssueValidations
|
4
|
+
class ContentValidation < Validation
|
5
|
+
def valid?
|
6
|
+
!has_content? || (content.is_a?(Hash) && content["body"].is_a?(String))
|
7
|
+
end
|
8
|
+
|
9
|
+
def message
|
10
|
+
"Content must be a hash containing a 'body' key with string contents"
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def has_content?
|
16
|
+
object.key?("content")
|
17
|
+
end
|
18
|
+
|
19
|
+
def content
|
20
|
+
object["content"]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module CC
|
2
|
+
module Analyzer
|
3
|
+
module IssueValidations
|
4
|
+
class LocationFormatValidation < Validation
|
5
|
+
def valid?
|
6
|
+
if location["lines"]
|
7
|
+
valid_lines?(location["lines"])
|
8
|
+
elsif location["positions"]
|
9
|
+
valid_positions?(location["positions"])
|
10
|
+
else
|
11
|
+
false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def message
|
16
|
+
"Location is not formatted correctly"
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def location
|
22
|
+
@location ||= object.fetch("location", {})
|
23
|
+
end
|
24
|
+
|
25
|
+
def valid_positions?(positions)
|
26
|
+
positions.is_a?(Hash) &&
|
27
|
+
valid_position?(positions["begin"]) &&
|
28
|
+
valid_position?(positions["end"])
|
29
|
+
end
|
30
|
+
|
31
|
+
def valid_position?(position)
|
32
|
+
position &&
|
33
|
+
(
|
34
|
+
[position["line"], position["column"]].all? { |value| value.is_a?(Integer) } ||
|
35
|
+
position["offset"].is_a?(Integer)
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
def valid_lines?(lines)
|
40
|
+
lines.is_a?(Hash) && [lines["begin"], lines["end"]].all? { |value| value.is_a?(Integer) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module CC
|
2
|
+
module Analyzer
|
3
|
+
module IssueValidations
|
4
|
+
class OtherLocationsFormatValidation < Validation
|
5
|
+
CHECKS = [
|
6
|
+
LocationFormatValidation,
|
7
|
+
PathExistenceValidation,
|
8
|
+
PathPresenceValidation,
|
9
|
+
RelativePathValidation,
|
10
|
+
].freeze
|
11
|
+
|
12
|
+
def valid?
|
13
|
+
if object["other_locations"]
|
14
|
+
object["other_locations"].is_a?(Array) &&
|
15
|
+
object["other_locations"].all?(&method(:other_location_valid?))
|
16
|
+
else
|
17
|
+
true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def message
|
22
|
+
"Other locations are not formatted correctly"
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def other_location_valid?(location)
|
28
|
+
CHECKS.all? do |klass|
|
29
|
+
klass.new("location" => location).valid?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module CC
|
2
|
+
module Analyzer
|
3
|
+
module IssueValidations
|
4
|
+
class PathExistenceValidation < Validation
|
5
|
+
def valid?
|
6
|
+
File.exist?(path)
|
7
|
+
end
|
8
|
+
|
9
|
+
def message
|
10
|
+
"File does not exist: '#{path}'"
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def path
|
16
|
+
object.fetch("location", {}).fetch("path", "")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module CC
|
2
|
+
module Analyzer
|
3
|
+
module IssueValidations
|
4
|
+
class PathIsFileValidation < Validation
|
5
|
+
def valid?
|
6
|
+
File.file?(path)
|
7
|
+
end
|
8
|
+
|
9
|
+
def message
|
10
|
+
"Path is not a file: '#{path}'"
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def path
|
16
|
+
object.fetch("location", {}).fetch("path", "")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module CC
|
2
|
+
module Analyzer
|
3
|
+
module IssueValidations
|
4
|
+
class PathPresenceValidation < Validation
|
5
|
+
def valid?
|
6
|
+
path.present?
|
7
|
+
end
|
8
|
+
|
9
|
+
def message
|
10
|
+
"Path must be present"
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def path
|
16
|
+
object.fetch("location", {})["path"]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
module CC
|
4
|
+
module Analyzer
|
5
|
+
module IssueValidations
|
6
|
+
class RelativePathValidation < Validation
|
7
|
+
def valid?
|
8
|
+
path &&
|
9
|
+
!path.start_with?("/") &&
|
10
|
+
relative_to?(MountedPath.code.container_path)
|
11
|
+
end
|
12
|
+
|
13
|
+
def message
|
14
|
+
"Path must be relative to the project directory"
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def relative_to?(directory)
|
20
|
+
expanded_base = Pathname.new(directory).expand_path.to_s
|
21
|
+
expanded_path = Pathname.new(path).expand_path.to_s
|
22
|
+
|
23
|
+
expanded_path.start_with?(expanded_base)
|
24
|
+
end
|
25
|
+
|
26
|
+
def path
|
27
|
+
object.fetch("location", {})["path"]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module CC
|
2
|
+
module Analyzer
|
3
|
+
module IssueValidations
|
4
|
+
class TypeValidation < Validation
|
5
|
+
def valid?
|
6
|
+
type && type.casecmp("issue").zero?
|
7
|
+
end
|
8
|
+
|
9
|
+
def message
|
10
|
+
"Type must be 'issue' but was '#{type}'"
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def type
|
16
|
+
object["type"]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module CC
|
2
|
+
module Analyzer
|
3
|
+
module IssueValidations
|
4
|
+
class Validation
|
5
|
+
def initialize(object)
|
6
|
+
@object = object
|
7
|
+
end
|
8
|
+
|
9
|
+
def valid?
|
10
|
+
raise NotImplementedError
|
11
|
+
end
|
12
|
+
|
13
|
+
def message
|
14
|
+
raise NotImplementedError
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_reader :object
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,18 +1,7 @@
|
|
1
1
|
module CC
|
2
2
|
module Analyzer
|
3
3
|
class IssueValidator
|
4
|
-
CHECKS =
|
5
|
-
IssueCategoryValidation,
|
6
|
-
IssueCheckNamePresenceValidation,
|
7
|
-
IssueDescriptionPresenceValidation,
|
8
|
-
IssueLocationFormatValidation,
|
9
|
-
IssueOtherLocationsFormatValidation,
|
10
|
-
IssuePathExistenceValidation,
|
11
|
-
IssuePathIsFileValidation,
|
12
|
-
IssuePathPresenceValidation,
|
13
|
-
IssueRelativePathValidation,
|
14
|
-
IssueTypeValidation,
|
15
|
-
].freeze
|
4
|
+
CHECKS = IssueValidations.validations.freeze
|
16
5
|
|
17
6
|
attr_reader :error
|
18
7
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeclimate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.35.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code Climate
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -183,17 +183,20 @@ files:
|
|
183
183
|
- lib/cc/analyzer/formatters/plain_text_formatter.rb
|
184
184
|
- lib/cc/analyzer/formatters/spinner.rb
|
185
185
|
- lib/cc/analyzer/issue.rb
|
186
|
-
- lib/cc/analyzer/issue_category_validation.rb
|
187
|
-
- lib/cc/analyzer/issue_check_name_presence_validation.rb
|
188
|
-
- lib/cc/analyzer/issue_description_presence_validation.rb
|
189
|
-
- lib/cc/analyzer/issue_location_format_validation.rb
|
190
|
-
- lib/cc/analyzer/issue_other_locations_format_validation.rb
|
191
|
-
- lib/cc/analyzer/issue_path_existence_validation.rb
|
192
|
-
- lib/cc/analyzer/issue_path_is_file_validation.rb
|
193
|
-
- lib/cc/analyzer/issue_path_presence_validation.rb
|
194
|
-
- lib/cc/analyzer/issue_relative_path_validation.rb
|
195
186
|
- lib/cc/analyzer/issue_sorter.rb
|
196
|
-
- lib/cc/analyzer/
|
187
|
+
- lib/cc/analyzer/issue_validations.rb
|
188
|
+
- lib/cc/analyzer/issue_validations/category_validation.rb
|
189
|
+
- lib/cc/analyzer/issue_validations/check_name_presence_validation.rb
|
190
|
+
- lib/cc/analyzer/issue_validations/content_validation.rb
|
191
|
+
- lib/cc/analyzer/issue_validations/description_presence_validation.rb
|
192
|
+
- lib/cc/analyzer/issue_validations/location_format_validation.rb
|
193
|
+
- lib/cc/analyzer/issue_validations/other_locations_format_validation.rb
|
194
|
+
- lib/cc/analyzer/issue_validations/path_existence_validation.rb
|
195
|
+
- lib/cc/analyzer/issue_validations/path_is_file_validation.rb
|
196
|
+
- lib/cc/analyzer/issue_validations/path_presence_validation.rb
|
197
|
+
- lib/cc/analyzer/issue_validations/relative_path_validation.rb
|
198
|
+
- lib/cc/analyzer/issue_validations/type_validation.rb
|
199
|
+
- lib/cc/analyzer/issue_validations/validation.rb
|
197
200
|
- lib/cc/analyzer/issue_validator.rb
|
198
201
|
- lib/cc/analyzer/location_description.rb
|
199
202
|
- lib/cc/analyzer/logging_container_listener.rb
|
@@ -203,7 +206,6 @@ files:
|
|
203
206
|
- lib/cc/analyzer/source_extractor.rb
|
204
207
|
- lib/cc/analyzer/source_fingerprint.rb
|
205
208
|
- lib/cc/analyzer/statsd_container_listener.rb
|
206
|
-
- lib/cc/analyzer/validation.rb
|
207
209
|
- lib/cc/cli.rb
|
208
210
|
- lib/cc/cli/analyze.rb
|
209
211
|
- lib/cc/cli/command.rb
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module CC
|
2
|
-
module Analyzer
|
3
|
-
class IssueCategoryValidation < Validation
|
4
|
-
CATEGORIES = [
|
5
|
-
"Bug Risk".freeze,
|
6
|
-
"Clarity".freeze,
|
7
|
-
"Compatibility".freeze,
|
8
|
-
"Complexity".freeze,
|
9
|
-
"Duplication".freeze,
|
10
|
-
"Performance".freeze,
|
11
|
-
"Security".freeze,
|
12
|
-
"Style".freeze,
|
13
|
-
].freeze
|
14
|
-
|
15
|
-
def valid?
|
16
|
-
object["categories"].present? && no_invalid_categories?
|
17
|
-
end
|
18
|
-
|
19
|
-
def message
|
20
|
-
"Category must be at least one of #{CATEGORIES.join(", ")}"
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def no_invalid_categories?
|
26
|
-
(CATEGORIES | object["categories"]) == CATEGORIES
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module CC
|
2
|
-
module Analyzer
|
3
|
-
class IssueLocationFormatValidation < Validation
|
4
|
-
def valid?
|
5
|
-
if location["lines"]
|
6
|
-
valid_lines?(location["lines"])
|
7
|
-
elsif location["positions"]
|
8
|
-
valid_positions?(location["positions"])
|
9
|
-
else
|
10
|
-
false
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def message
|
15
|
-
"Location is not formatted correctly"
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def location
|
21
|
-
@location ||= object.fetch("location", {})
|
22
|
-
end
|
23
|
-
|
24
|
-
def valid_positions?(positions)
|
25
|
-
positions.is_a?(Hash) &&
|
26
|
-
valid_position?(positions["begin"]) &&
|
27
|
-
valid_position?(positions["end"])
|
28
|
-
end
|
29
|
-
|
30
|
-
def valid_position?(position)
|
31
|
-
position &&
|
32
|
-
(
|
33
|
-
[position["line"], position["column"]].all? { |value| value.is_a?(Integer) } ||
|
34
|
-
position["offset"].is_a?(Integer)
|
35
|
-
)
|
36
|
-
end
|
37
|
-
|
38
|
-
def valid_lines?(lines)
|
39
|
-
lines.is_a?(Hash) && [lines["begin"], lines["end"]].all? { |value| value.is_a?(Integer) }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module CC
|
2
|
-
module Analyzer
|
3
|
-
class IssueOtherLocationsFormatValidation < Validation
|
4
|
-
CHECKS = [
|
5
|
-
IssueLocationFormatValidation,
|
6
|
-
IssuePathExistenceValidation,
|
7
|
-
IssuePathPresenceValidation,
|
8
|
-
IssueRelativePathValidation,
|
9
|
-
].freeze
|
10
|
-
|
11
|
-
def valid?
|
12
|
-
if object["other_locations"]
|
13
|
-
object["other_locations"].is_a?(Array) &&
|
14
|
-
object["other_locations"].all?(&method(:other_location_valid?))
|
15
|
-
else
|
16
|
-
true
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def message
|
21
|
-
"Other locations are not formatted correctly"
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def other_location_valid?(location)
|
27
|
-
CHECKS.all? do |klass|
|
28
|
-
klass.new("location" => location).valid?
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module CC
|
2
|
-
module Analyzer
|
3
|
-
class IssuePathExistenceValidation < Validation
|
4
|
-
def valid?
|
5
|
-
File.exist?(path)
|
6
|
-
end
|
7
|
-
|
8
|
-
def message
|
9
|
-
"File does not exist: '#{path}'"
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def path
|
15
|
-
object.fetch("location", {}).fetch("path", "")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module CC
|
2
|
-
module Analyzer
|
3
|
-
class IssuePathIsFileValidation < Validation
|
4
|
-
def valid?
|
5
|
-
File.file?(path)
|
6
|
-
end
|
7
|
-
|
8
|
-
def message
|
9
|
-
"Path is not a file: '#{path}'"
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def path
|
15
|
-
object.fetch("location", {}).fetch("path", "")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module CC
|
2
|
-
module Analyzer
|
3
|
-
class IssuePathPresenceValidation < Validation
|
4
|
-
def valid?
|
5
|
-
path.present?
|
6
|
-
end
|
7
|
-
|
8
|
-
def message
|
9
|
-
"Path must be present"
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def path
|
15
|
-
object.fetch("location", {})["path"]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require "pathname"
|
2
|
-
|
3
|
-
module CC
|
4
|
-
module Analyzer
|
5
|
-
class IssueRelativePathValidation < Validation
|
6
|
-
def valid?
|
7
|
-
path &&
|
8
|
-
!path.start_with?("/") &&
|
9
|
-
relative_to?(MountedPath.code.container_path)
|
10
|
-
end
|
11
|
-
|
12
|
-
def message
|
13
|
-
"Path must be relative to the project directory"
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def relative_to?(directory)
|
19
|
-
expanded_base = Pathname.new(directory).expand_path.to_s
|
20
|
-
expanded_path = Pathname.new(path).expand_path.to_s
|
21
|
-
|
22
|
-
expanded_path.start_with?(expanded_base)
|
23
|
-
end
|
24
|
-
|
25
|
-
def path
|
26
|
-
object.fetch("location", {})["path"]
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module CC
|
2
|
-
module Analyzer
|
3
|
-
class IssueTypeValidation < Validation
|
4
|
-
def valid?
|
5
|
-
type && type.casecmp("issue").zero?
|
6
|
-
end
|
7
|
-
|
8
|
-
def message
|
9
|
-
"Type must be 'issue' but was '#{type}'"
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def type
|
15
|
-
object["type"]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module CC
|
2
|
-
module Analyzer
|
3
|
-
class Validation
|
4
|
-
def initialize(object)
|
5
|
-
@object = object
|
6
|
-
end
|
7
|
-
|
8
|
-
def valid?
|
9
|
-
raise NotImplementedError
|
10
|
-
end
|
11
|
-
|
12
|
-
def message
|
13
|
-
raise NotImplementedError
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
attr_reader :object
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|