Skip to content

Commit 7e18a40

Browse files
committed
enable linting
Fix luacheck warnings. See also tarantool/cartridge@c94918c
1 parent 559f983 commit 7e18a40

File tree

6 files changed

+51
-23
lines changed

6 files changed

+51
-23
lines changed

graphql/execute.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ local function mergeSelectionSets(fields)
6767
return selections
6868
end
6969

70-
local function defaultResolver(object, arguments, info)
70+
local function defaultResolver(object, _, info)
7171
return object[info.fieldASTs[1].name.value]
7272
end
7373

@@ -249,9 +249,9 @@ local function getFieldEntry(objectType, object, fields, context)
249249
end)
250250

251251
--[[
252-
Make arguments ordered map using metatble.
252+
Make arguments ordered map using metatable.
253253
This way callback can use positions to access argument values.
254-
For example buisness logic depends on argument positions to choose
254+
For example business logic depends on argument positions to choose
255255
appropriate storage iteration.
256256
]]
257257
local positions = {}

graphql/introspection.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ __Type = types.object({
238238

239239
possibleTypes = {
240240
kind = types.list(types.nonNull(__Type)),
241-
resolve = function(kind, arguments, context)
241+
resolve = function(kind, _, context)
242242
if kind.__type == 'Interface' or kind.__type == 'Union' then
243243
return context.schema:getPossibleTypes(kind)
244244
end

graphql/parse.lua

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
_G._ENV = rawget(_G, "_ENV") -- to get lulpeg work under strict mode
22
local lpeg = require 'lulpeg'
33
local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V
4-
local C, Ct, Cmt, Cg, Cc, Cf, Cmt = lpeg.C, lpeg.Ct, lpeg.Cmt, lpeg.Cg, lpeg.Cc, lpeg.Cf, lpeg.Cmt
4+
local C, Ct, Cmt = lpeg.C, lpeg.Ct, lpeg.Cmt
55

66
local line
77
local lastLinePos
@@ -261,8 +261,22 @@ local graphQL = P {
261261
definition = _'operation' + _'fragmentDefinition',
262262

263263
operationType = C(P'query' + P'mutation'),
264-
operation = (_'operationType' * ws * maybe(name) * maybe('variableDefinitions') * maybe('directives') * _'selectionSet' + _'selectionSet') / cOperation,
265-
fragmentDefinition = 'fragment' * ws * fragmentName * ws * _'typeCondition' * ws * _'selectionSet' / cFragmentDefinition,
264+
operation = (_'operationType'
265+
* ws
266+
* maybe(name)
267+
* maybe('variableDefinitions')
268+
* maybe('directives')
269+
* _'selectionSet'
270+
+ _'selectionSet'
271+
) / cOperation,
272+
fragmentDefinition = 'fragment'
273+
* ws
274+
* fragmentName
275+
* ws
276+
* _'typeCondition'
277+
* ws
278+
* _'selectionSet'
279+
/ cFragmentDefinition,
266280

267281
selectionSet = ws * '{' * ws * list('selection') * ws * '}' / cSelectionSet,
268282
selection = ws * (_'field' + _'fragmentSpread' + _'inlineFragment'),
@@ -278,10 +292,20 @@ local graphQL = P {
278292
directive = '@' * name * maybe('arguments') / cDirective,
279293
directives = ws * list('directive', 1) * ws,
280294

281-
variableDefinition = ws * variable * ws * ':' * ws * _'type' * (ws * '=' * _'value') ^ -1 * comma * ws / cVariableDefinition,
295+
variableDefinition = ws
296+
* variable
297+
* ws
298+
* ':'
299+
* ws
300+
* _'type'
301+
* (ws * '=' * _'value') ^ -1
302+
* comma
303+
* ws
304+
/ cVariableDefinition,
282305
variableDefinitions = ws * '(' * list('variableDefinition', 1) * ')',
283306

284-
value = ws * (variable + _'objectValue' + _'listValue' + enumValue + stringValue + booleanValue + floatValue + intValue),
307+
value = ws
308+
* (variable + _'objectValue' + _'listValue' + enumValue + stringValue + booleanValue + floatValue + intValue),
285309
listValue = '[' * list('value') * ']' / cList,
286310
objectFieldValue = ws * C(rawName) * ws * ':' * ws * _'value' * comma / cObjectField,
287311
objectValue = '{' * ws * list('objectFieldValue') * ws * '}' / cObject,
@@ -318,4 +342,5 @@ local function parse(str)
318342
return graphQL:match(str) or error('Syntax error near line ' .. line, 2)
319343
end
320344

345+
321346
return {parse=parse}

graphql/rules.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ function rules.unambiguousSelections(node, context)
182182
validateSelectionSet(node, context.objects[#context.objects])
183183
end
184184

185-
function rules.uniqueArgumentNames(node, context)
185+
function rules.uniqueArgumentNames(node, _)
186186
if node.arguments then
187187
local arguments = {}
188188
for _, argument in ipairs(node.arguments) do
@@ -222,7 +222,7 @@ function rules.requiredArgumentsPresent(node, context)
222222
end
223223
end
224224

225-
function rules.uniqueFragmentNames(node, context)
225+
function rules.uniqueFragmentNames(node, _)
226226
local fragments = {}
227227
for _, definition in ipairs(node.definitions) do
228228
if definition.kind == 'fragmentDefinition' then
@@ -344,7 +344,7 @@ function rules.fragmentSpreadIsPossible(node, context)
344344
end
345345
end
346346

347-
function rules.uniqueInputObjectFields(node, context)
347+
function rules.uniqueInputObjectFields(node, _)
348348
local function validateValue(value)
349349
if value.kind == 'listType' or value.kind == 'nonNullType' then
350350
return validateValue(value.type)

graphql/types.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ end
289289

290290
types.int = types.scalar({
291291
name = 'Int',
292-
description = "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values from -(2^31) to 2^31 - 1, inclusive.",
292+
description = "The `Int` scalar type represents non-fractional signed whole numeric values. " ..
293+
"Int can represent values from -(2^31) to 2^31 - 1, inclusive.",
293294
serialize = coerceInt,
294295
parseValue = coerceInt,
295296
parseLiteral = function(node)
@@ -302,7 +303,8 @@ types.int = types.scalar({
302303

303304
types.long = types.scalar({
304305
name = 'Long',
305-
description = "The `Long` scalar type represents non-fractional signed whole numeric values. Long can represent values from -(2^52) to 2^52 - 1, inclusive.",
306+
description = "The `Long` scalar type represents non-fractional signed whole numeric values. " ..
307+
"Long can represent values from -(2^52) to 2^52 - 1, inclusive.",
306308
serialize = coerceLong,
307309
parseValue = coerceLong,
308310
parseLiteral = function(node)
@@ -329,7 +331,8 @@ types.float = types.scalar({
329331

330332
types.string = types.scalar({
331333
name = 'String',
332-
description = "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.",
334+
description = "The `String` scalar type represents textual data, represented as UTF-8 character sequences. " ..
335+
"The String type is most often used by GraphQL to represent free-form human-readable text.",
333336
serialize = tostring,
334337
parseValue = tostring,
335338
parseLiteral = function(node)

graphql/validate.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ local visitors = {
2727
end
2828
end,
2929

30-
children = function(node, context)
30+
children = function(node, _)
3131
return node.definitions
3232
end,
3333

@@ -41,7 +41,7 @@ local visitors = {
4141
context.variableReferences = {}
4242
end,
4343

44-
exit = function(node, context)
44+
exit = function(_, context)
4545
table.remove(context.objects)
4646
context.currentOperation = nil
4747
context.variableReferences = nil
@@ -85,7 +85,7 @@ local visitors = {
8585
end
8686
end,
8787

88-
exit = function(node, context)
88+
exit = function(_, context)
8989
table.remove(context.objects)
9090
end,
9191

@@ -135,11 +135,11 @@ local visitors = {
135135
table.insert(context.objects, kind)
136136
end,
137137

138-
exit = function(node, context)
138+
exit = function(_, context)
139139
table.remove(context.objects)
140140
end,
141141

142-
children = function(node, context)
142+
children = function(node, _)
143143
if node.selectionSet then
144144
return {node.selectionSet}
145145
end
@@ -205,7 +205,7 @@ local visitors = {
205205
end
206206
end,
207207

208-
exit = function(node, context)
208+
exit = function(_, context)
209209
table.remove(context.objects)
210210
end,
211211

@@ -223,7 +223,7 @@ local visitors = {
223223
table.insert(context.objects, kind)
224224
end,
225225

226-
exit = function(node, context)
226+
exit = function(_, context)
227227
table.remove(context.objects)
228228
end,
229229

@@ -293,7 +293,7 @@ local visitors = {
293293
},
294294

295295
directive = {
296-
children = function(node, context)
296+
children = function(node, _)
297297
return node.arguments
298298
end
299299
}

0 commit comments

Comments
 (0)