codeqa 0.4.0.pre → 0.4.0.pre2
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/Gemfile +1 -3
- data/README.md +5 -4
- data/bin/codeqa +6 -1
- data/codeqa.gemspec +4 -0
- data/lib/codeqa/checkers/html_validator.rb +7 -3
- data/lib/codeqa/checkers/rubocop_full.rb +11 -11
- data/lib/codeqa/utils/erb_sanitizer.rb +1 -1
- data/lib/codeqa/version.rb +1 -1
- data/spec/lib/codeqa/checkers/html_validator_spec.rb +34 -20
- metadata +44 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b47b37862da4f231fa163a9161ea66758c543de5
|
4
|
+
data.tar.gz: a36f9e4ac2f21942121b32be320dccfbf0198b17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23e80489e8084d42a8d3a7c760bd70af2a34f7023fa9612c507d0800e8cd334e06164b9e366a277c263a2b639a674db69ee191b314cf159b4e3f1dbf5d2c9419
|
7
|
+
data.tar.gz: f1c7db9caef0fed024e0f6a64d6de6dc931adfbed55c37718eeab541a3861cbc0f834329034b734bf7e07329e78cee9c311fa62094cb2c1df21901d4d4a058c7
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Codeqa
|
2
2
|
|
3
|
-
[](https://coveralls.io/r/experteer/codeqa)
|
6
|
-
[](https://rubygems.org/gems/codeqa)
|
4
|
+
[](https://travis-ci.org/experteer/codeqa)
|
5
|
+
[](https://coveralls.io/r/experteer/codeqa)
|
6
|
+
[](https://codeclimate.com/github/experteer/codeqa)
|
7
7
|
|
8
8
|
With codeqa you can check your code to comply to certain coding rules (utf8 only chars, indenting) or to avoid typical errors or
|
9
9
|
enforce deprecations. You might even put it into a pre commit hook.
|
@@ -85,6 +85,7 @@ end
|
|
85
85
|
- erb
|
86
86
|
- CheckErb (tests erb template for syntax errors using either `erb` or `action_view`
|
87
87
|
- CheckErbHtml (removes all erb tags and tests with `tidy` if the template is valid XML)
|
88
|
+
- HtmlValidator (uses Nokogiri to check stripped html.erb files against XML errors)
|
88
89
|
- yard
|
89
90
|
- CheckYard (checks YARD for warnings)
|
90
91
|
- CheckRubySyntax (runs file though `ruby -c`, use RubocopLint if possible)
|
data/bin/codeqa
CHANGED
@@ -15,9 +15,14 @@ ARGV.options do |opts|
|
|
15
15
|
opts.separator ''
|
16
16
|
opts.separator 'Specific Options:'
|
17
17
|
|
18
|
-
opts.on('-s', '--silent', 'No output
|
18
|
+
opts.on('-s', '--silent', 'No output') do
|
19
19
|
options[:silent] = true
|
20
20
|
end
|
21
|
+
|
22
|
+
opts.on('-e', '--silent-success', 'only Output errors') do
|
23
|
+
options[:silent_success] = true
|
24
|
+
end
|
25
|
+
|
21
26
|
opts.on('-f', '--fail-fast', 'Fail right after the first error.') do
|
22
27
|
options[:failfast] = true
|
23
28
|
end
|
data/codeqa.gemspec
CHANGED
@@ -18,7 +18,11 @@ Gem::Specification.new do |gem|
|
|
18
18
|
|
19
19
|
gem.required_ruby_version = '>= 2.0'
|
20
20
|
|
21
|
+
gem.add_dependency 'multi_json', '>= 1.0'
|
22
|
+
|
21
23
|
gem.add_development_dependency 'rake'
|
22
24
|
gem.add_development_dependency 'rspec', '>=3.0'
|
23
25
|
gem.add_development_dependency 'yard'
|
26
|
+
gem.add_development_dependency 'nokogiri'
|
27
|
+
gem.add_development_dependency 'rubocop'
|
24
28
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'codeqa/utils/erb_sanitizer'
|
2
|
+
require 'nokogiri'
|
2
3
|
|
3
4
|
module Codeqa
|
4
5
|
module Checkers
|
@@ -23,7 +24,8 @@ module Codeqa
|
|
23
24
|
/Opening and ending tag mismatch: (special line 1|\w+ line 1 and special)/,
|
24
25
|
/Premature end of data in tag special/,
|
25
26
|
/Extra content at the end of the document/,
|
26
|
-
/xmlParseEntityRef: no name
|
27
|
+
/xmlParseEntityRef: no name/,
|
28
|
+
/Entity 'nbsp' not defined/
|
27
29
|
)
|
28
30
|
def check
|
29
31
|
return unless self.class.nokogiri?
|
@@ -31,14 +33,16 @@ module Codeqa
|
|
31
33
|
|
32
34
|
doc.errors.delete_if{ |e| e.message =~ REMOVED_NOKOGIRI_ERRORS }
|
33
35
|
errors.add(:source, sourcefile.content) unless doc.errors.empty?
|
34
|
-
# errors.add(:source, stripped_html) unless doc.errors.empty?
|
35
36
|
doc.errors.each do |error|
|
36
37
|
errors.add(error.line, error.message) unless error.warning?
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
41
|
def stripped_html
|
41
|
-
|
42
|
+
ErbSanitizer.
|
43
|
+
new(sourcefile.content).
|
44
|
+
result.
|
45
|
+
gsub(%r{<script[ >](.*)</script>}m){ "<!-- script#{"\n" * $1.scan("\n").count} /script -->" }
|
42
46
|
end
|
43
47
|
|
44
48
|
def self.nokogiri?
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'multi_json'
|
2
2
|
|
3
3
|
module Codeqa
|
4
4
|
module Checkers
|
@@ -45,15 +45,14 @@ module Codeqa
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def handle_rubocop_results(raw)
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
48
|
+
MultiJson.load(raw)['files'].
|
49
|
+
reject{ |f| f['offenses'].empty? }.
|
50
|
+
each do |file|
|
51
|
+
file['offenses'].each do |offense|
|
52
|
+
position = [offense['location']['line'], offense['location']['column']]
|
53
|
+
errors.add(position, "#{offense['cop_name']}: #{offense['message']}")
|
54
|
+
end
|
55
|
+
end
|
57
56
|
end
|
58
57
|
def self.rubocop?
|
59
58
|
@loaded ||= begin
|
@@ -63,7 +62,8 @@ module Codeqa
|
|
63
62
|
end
|
64
63
|
|
65
64
|
# Since using the json format we only care about stdout
|
66
|
-
# stderr will be
|
65
|
+
# stderr will be silenced
|
66
|
+
# (internal rubocop errors/warning will be printed there)
|
67
67
|
def capture
|
68
68
|
$stdout, stdout = StringIO.new, $stdout
|
69
69
|
$stderr, stderr = StringIO.new, $stderr
|
data/lib/codeqa/version.rb
CHANGED
@@ -54,25 +54,39 @@ describe Codeqa::Checkers::HtmlValidator do
|
|
54
54
|
checker = check_with(described_class, source)
|
55
55
|
expect(checker).to be_success
|
56
56
|
end
|
57
|
+
it "should no complain about nbsp 'spaces'" do
|
58
|
+
source = source_with('<div>something fooo</div>')
|
59
|
+
checker = check_with(described_class, source)
|
60
|
+
expect(checker).to be_success
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'script tags' do
|
64
|
+
it 'should replace script tags with html comment' do
|
65
|
+
text = '<div><script>foo</script></div>'
|
66
|
+
source = source_with(text)
|
67
|
+
checker = described_class.new(source)
|
68
|
+
expect(checker.stripped_html).to eq('<div><!-- script /script --></div>')
|
69
|
+
end
|
57
70
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
71
|
+
it 'should replace multiline script tags while keeping the linecount correct' do
|
72
|
+
text = <<-EOR
|
73
|
+
<div>
|
74
|
+
<script>
|
75
|
+
var some = 'javascript';
|
76
|
+
console.log(some);
|
77
|
+
</script>
|
78
|
+
</div>
|
79
|
+
EOR
|
80
|
+
source = source_with(text)
|
81
|
+
checker = described_class.new(source)
|
82
|
+
expect(checker.stripped_html).to eq(<<-EOR)
|
83
|
+
<div>
|
84
|
+
<!-- script
|
85
|
+
|
86
|
+
|
87
|
+
/script -->
|
88
|
+
</div>
|
89
|
+
EOR
|
90
|
+
end
|
91
|
+
end
|
78
92
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeqa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.0.
|
4
|
+
version: 0.4.0.pre2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Schrammel
|
@@ -9,8 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-08-
|
12
|
+
date: 2014-08-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: multi_json
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.0'
|
14
28
|
- !ruby/object:Gem::Dependency
|
15
29
|
name: rake
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,6 +67,34 @@ dependencies:
|
|
53
67
|
- - ">="
|
54
68
|
- !ruby/object:Gem::Version
|
55
69
|
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: nokogiri
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rubocop
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
56
98
|
description: Checks your code (esp Rails) for common errors
|
57
99
|
email:
|
58
100
|
- peter.schrammel@experteer.com
|