sqlint 0.1.1 → 0.1.2
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/README.md +1 -1
- data/bin/sqlint +31 -24
- data/lib/sqlint/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b14888e061953471546b3c17225b83b056b2d738
|
4
|
+
data.tar.gz: 3d760e0838c3a4ca4caa03e397d443c52b1cf131
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19bcbb3e7c9532b315a3c55f6624f89eb9fd449b8bdd65b13b4bcf15ed1585d5ab1dfa88588814bf52bea190663519b9c1df9affb53f8e9d6ea70881e614bcde
|
7
|
+
data.tar.gz: e7640ef540312e72b0f1a68d3664ec29b0f7accd83d38e122bf79bcbb2a5af8966a0399e158a51c1d1499b1539f5736d8d45c139bd36366bdd442ac9ab9be20e
|
data/README.md
CHANGED
@@ -35,7 +35,7 @@ Support for `sqlint` is provided for the following editors:
|
|
35
35
|
|
36
36
|
- Emacs, via [Flycheck](https://github.com/flycheck/flycheck)
|
37
37
|
- VIM, via [Syntastic](https://github.com/scrooloose/syntastic)
|
38
|
-
- SublimeText, via
|
38
|
+
- SublimeText, via [SublimeLinter](https://github.com/SublimeLinter/SublimeLinter3/)
|
39
39
|
|
40
40
|
### Authors
|
41
41
|
|
data/bin/sqlint
CHANGED
@@ -5,14 +5,12 @@ require 'pg_query'
|
|
5
5
|
require 'sqlint'
|
6
6
|
require 'optparse'
|
7
7
|
|
8
|
-
LIMIT = 1000
|
9
|
-
|
10
8
|
options = { limit: 1000 }
|
11
9
|
optparse = OptionParser.new do |opts|
|
12
|
-
opts.banner = "Usage: #{File.basename($0)} [options] file.sql ..."
|
10
|
+
opts.banner = "Usage: #{File.basename($0)} [options] [file.sql ...]"
|
13
11
|
opts.separator ""
|
14
12
|
opts.separator "Options:"
|
15
|
-
opts.on("--limit=N", Integer, "Limit checking to N errors") do |n|
|
13
|
+
opts.on("--limit=N", Integer, "Limit checking to N errors (default: #{options[:limit]})") do |n|
|
16
14
|
options[:limit] = n
|
17
15
|
end
|
18
16
|
opts.on_tail("-h", "--help", "Print this help") do
|
@@ -25,10 +23,6 @@ optparse = OptionParser.new do |opts|
|
|
25
23
|
end
|
26
24
|
end
|
27
25
|
optparse.parse!(ARGV)
|
28
|
-
if ARGV.empty?
|
29
|
-
puts optparse
|
30
|
-
exit 1
|
31
|
-
end
|
32
26
|
|
33
27
|
ERROR_TYPES = {error: "ERROR", warning: "WARNING"}
|
34
28
|
|
@@ -40,25 +34,38 @@ class String
|
|
40
34
|
end
|
41
35
|
end
|
42
36
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
message_lines.each do |line|
|
56
|
-
puts " " + line.sanitise
|
57
|
-
end
|
37
|
+
def display_lint(lint)
|
38
|
+
message_lines = lint.message.split("\n")
|
39
|
+
puts [
|
40
|
+
lint.filename,
|
41
|
+
lint.line,
|
42
|
+
lint.column,
|
43
|
+
ERROR_TYPES[lint.type] + " " + message_lines.shift.sanitise
|
44
|
+
].join(":")
|
45
|
+
message_lines.each do |line|
|
46
|
+
puts " " + line.sanitise
|
47
|
+
end
|
48
|
+
end
|
58
49
|
|
59
|
-
|
50
|
+
def each_input_file(&block)
|
51
|
+
if ARGV.empty?
|
52
|
+
yield [STDIN, "stdin"]
|
53
|
+
else
|
54
|
+
ARGV.each do |filename|
|
55
|
+
File.open(filename, 'r') do |file|
|
56
|
+
yield [file, filename]
|
57
|
+
end
|
60
58
|
end
|
61
59
|
end
|
62
60
|
end
|
63
61
|
|
62
|
+
saw_errors = false
|
63
|
+
each_input_file do |file, filename|
|
64
|
+
results = SQLint::Linter.new(filename, file).run.first(options[:limit])
|
65
|
+
results.each do |lint|
|
66
|
+
display_lint(lint)
|
67
|
+
end
|
68
|
+
saw_errors ||= results.any? { |lint| lint.type == :error }
|
69
|
+
end
|
70
|
+
|
64
71
|
exit 1 if saw_errors
|
data/lib/sqlint/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqlint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Purcell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-10-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pg_query
|
@@ -67,8 +67,7 @@ dependencies:
|
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '1.3'
|
70
|
-
description:
|
71
|
-
Simple SQL linter.
|
70
|
+
description: " Simple SQL linter.\n"
|
72
71
|
email: steve@sanityinc.com
|
73
72
|
executables:
|
74
73
|
- sqlint
|