Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sqlint
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
sqlint
Commits
da84d5c4
Commit
da84d5c4
authored
9 years ago
by
Kieran Trezona-le Comte
Browse files
Options
Downloads
Patches
Plain Diff
Better names
parent
9ae8a665
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/sqlint/linter.rb
+4
-4
4 additions, 4 deletions
lib/sqlint/linter.rb
with
4 additions
and
4 deletions
lib/sqlint/linter.rb
+
4
−
4
View file @
da84d5c4
...
@@ -15,7 +15,7 @@ module SQLint
...
@@ -15,7 +15,7 @@ module SQLint
[].
tap
do
|
results
|
[].
tap
do
|
results
|
state
=
ParseState
.
new
(
@input
,
0
)
state
=
ParseState
.
new
(
@input
,
0
)
while
state
!=
END_PARSE
while
state
!=
END_PARSE
error
,
new_parse_state
=
foo
(
state
)
error
,
new_parse_state
=
parse_next_error
(
state
)
results
<<
error
if
error
results
<<
error
if
error
state
=
new_parse_state
state
=
new_parse_state
end
end
...
@@ -24,13 +24,13 @@ module SQLint
...
@@ -24,13 +24,13 @@ module SQLint
private
private
def
foo
(
parse_state
)
def
parse_next_error
(
parse_state
)
begin
begin
PgQuery
.
parse
(
parse_state
.
input
)
PgQuery
.
parse
(
parse_state
.
input
)
[
nil
,
END_PARSE
]
[
nil
,
END_PARSE
]
rescue
PgQuery
::
ParseError
=>
e
rescue
PgQuery
::
ParseError
=>
e
offset
=
e
.
location
+
parse_state
.
offset
offset
=
e
.
location
+
parse_state
.
offset
line_number
,
column_number
=
find_position
(
offset
)
line_number
,
column_number
=
find_
absolute_
position
(
offset
)
lint
=
Lint
.
new
(
@filename
,
line_number
,
column_number
,
:error
,
e
.
message
)
lint
=
Lint
.
new
(
@filename
,
line_number
,
column_number
,
:error
,
e
.
message
)
input_from_error
=
parse_state
.
input
[
e
.
location
..-
1
]
input_from_error
=
parse_state
.
input
[
e
.
location
..-
1
]
...
@@ -48,7 +48,7 @@ module SQLint
...
@@ -48,7 +48,7 @@ module SQLint
end
end
end
end
def
find_position
(
offset
)
def
find_
absolute_
position
(
offset
)
lines_before_error
=
@input
[
0
...
(
offset
)].
split
(
"
\n
"
)
lines_before_error
=
@input
[
0
...
(
offset
)].
split
(
"
\n
"
)
line_number
=
lines_before_error
.
size
line_number
=
lines_before_error
.
size
column_number
=
lines_before_error
.
any?
?
lines_before_error
.
last
.
size
:
1
column_number
=
lines_before_error
.
any?
?
lines_before_error
.
last
.
size
:
1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment