11@enum (LintCodes,
2- MissingRef,
3- IncorrectCallArgs,
4- IncorrectIterSpec,
5- NothingEquality,
6- NothingNotEq,
7- ConstIfCondition,
8- EqInIfConditional,
9- PointlessOR,
10- PointlessAND,
11- UnusedBinding,
12- InvalidTypeDeclaration,
13- UnusedTypeParameter,
14- IncludeLoop,
15- MissingFile,
16- InvalidModuleName,
17- TypePiracy,
18- UnusedFunctionArgument,
19- CannotDeclareConst,
20- InvalidRedefofConst,
21- NotEqDef,
22- KwDefaultMismatch,
23- InappropriateUseOfLiteral,
24- ShouldBeInALoop,
25- TypeDeclOnGlobalVariable,
26- UnsupportedConstLocalVariable,
27- UnassignedKeywordArgument,
28- CannotDefineFuncAlreadyHasValue,
29- DuplicateFuncArgName,
30- IncludePathContainsNULL)
2+ MissingRef,
3+ IncorrectCallArgs,
4+ IncorrectIterSpec,
5+ NothingEquality,
6+ NothingNotEq,
7+ ConstIfCondition,
8+ EqInIfConditional,
9+ PointlessOR,
10+ PointlessAND,
11+ UnusedBinding,
12+ InvalidTypeDeclaration,
13+ UnusedTypeParameter,
14+ IncludeLoop,
15+ MissingFile,
16+ InvalidModuleName,
17+ TypePiracy,
18+ UnusedFunctionArgument,
19+ CannotDeclareConst,
20+ InvalidRedefofConst,
21+ NotEqDef,
22+ KwDefaultMismatch,
23+ InappropriateUseOfLiteral,
24+ ShouldBeInALoop,
25+ TypeDeclOnGlobalVariable,
26+ UnsupportedConstLocalVariable,
27+ UnassignedKeywordArgument,
28+ CannotDefineFuncAlreadyHasValue,
29+ DuplicateFuncArgName,
30+ IncludePathContainsNULL)
3131
3232
3333
@@ -59,7 +59,7 @@ const LintCodeDescriptions = Dict{LintCodes,String}(IncorrectCallArgs => "Possib
5959 CannotDefineFuncAlreadyHasValue => " Cannot define function ; it already has a value." ,
6060 DuplicateFuncArgName => " Function argument name not unique." ,
6161 IncludePathContainsNULL => " Cannot include file, path cotains NULL characters."
62- )
62+ )
6363
6464haserror (m:: Meta ) = m. error != = nothing
6565haserror (x:: EXPR ) = hasmeta (x) && haserror (x. meta)
@@ -173,9 +173,9 @@ function func_nargs(x::EXPR)
173173 maxargs != = typemax (Int) && (maxargs += 1 )
174174 end
175175 elseif issplat (arg) ||
176- (isdeclaration (arg) &&
177- ((isidentifier (arg. args[2 ]) && valofid (arg. args[2 ]) == " Vararg" ) ||
178- (iscurly (arg. args[2 ]) && isidentifier (arg. args[2 ]. args[1 ]) && valofid (arg. args[2 ]. args[1 ]) == " Vararg" )))
176+ (isdeclaration (arg) &&
177+ ((isidentifier (arg. args[2 ]) && valofid (arg. args[2 ]) == " Vararg" ) ||
178+ (iscurly (arg. args[2 ]) && isidentifier (arg. args[2 ]. args[1 ]) && valofid (arg. args[2 ]. args[1 ]) == " Vararg" )))
179179 maxargs = typemax (Int)
180180 else
181181 minargs += 1
239239# compare_f_call(m_counts, call_counts) = true # fallback method
240240
241241function compare_f_call (
242- (ref_minargs, ref_maxargs, ref_kws, kwsplat),
243- (act_minargs, act_maxargs, act_kws),
244- )
242+ (ref_minargs, ref_maxargs, ref_kws, kwsplat),
243+ (act_minargs, act_maxargs, act_kws),
244+ )
245245 # check matching on positional arguments
246246 if act_maxargs == typemax (Int)
247247 act_minargs <= act_maxargs < ref_minargs && return false
@@ -261,10 +261,10 @@ end
261261
262262function is_something_with_methods (x:: Binding )
263263 (CoreTypes. isfunction (x. type) && x. val isa EXPR) ||
264- (CoreTypes. isdatatype (x. type) && x. val isa EXPR && CSTParser. defines_struct (x. val)) ||
265- (x. val isa SymbolServer. FunctionStore || x. val isa SymbolServer. DataTypeStore)
264+ (CoreTypes. isdatatype (x. type) && x. val isa EXPR && CSTParser. defines_struct (x. val)) ||
265+ (x. val isa SymbolServer. FunctionStore || x. val isa SymbolServer. DataTypeStore)
266266end
267- is_something_with_methods (x:: T ) where T <: Union{SymbolServer.FunctionStore,SymbolServer.DataTypeStore} = true
267+ is_something_with_methods (x:: T ) where {T <: Union{SymbolServer.FunctionStore,SymbolServer.DataTypeStore} } = true
268268is_something_with_methods (x) = false
269269
270270function check_call (x, env:: ExternalEnv )
@@ -364,14 +364,14 @@ end
364364function check_nothing_equality (x:: EXPR , env:: ExternalEnv )
365365 if isbinarycall (x) && length (x. args) == 3
366366 if valof (x. args[1 ]) == " ==" && (
367- (valof (x. args[2 ]) == " nothing" && refof (x. args[2 ]) === getsymbols (env)[:Core ][:nothing ]) ||
368- (valof (x. args[3 ]) == " nothing" && refof (x. args[3 ]) === getsymbols (env)[:Core ][:nothing ])
369- )
367+ (valof (x. args[2 ]) == " nothing" && refof (x. args[2 ]) === getsymbols (env)[:Core ][:nothing ]) ||
368+ (valof (x. args[3 ]) == " nothing" && refof (x. args[3 ]) === getsymbols (env)[:Core ][:nothing ])
369+ )
370370 seterror! (x. args[1 ], NothingEquality)
371371 elseif valof (x. args[1 ]) == " !=" && (
372- (valof (x. args[2 ]) == " nothing" && refof (x. args[2 ]) === getsymbols (env)[:Core ][:nothing ]) ||
373- (valof (x. args[3 ]) == " nothing" && refof (x. args[3 ]) === getsymbols (env)[:Core ][:nothing ])
374- )
372+ (valof (x. args[2 ]) == " nothing" && refof (x. args[2 ]) === getsymbols (env)[:Core ][:nothing ]) ||
373+ (valof (x. args[3 ]) == " nothing" && refof (x. args[3 ]) === getsymbols (env)[:Core ][:nothing ])
374+ )
375375 seterror! (x. args[1 ], NothingNotEq)
376376 end
377377 end
463463
464464function check_modulename (x:: EXPR )
465465 if CSTParser. defines_module (x) && # x is a module
466- scopeof (x) isa Scope && parentof (scopeof (x)) isa Scope && # it has a scope and a parent scope
467- CSTParser. defines_module (parentof (scopeof (x)). expr) && # the parent scope is a module
468- valof (CSTParser. get_name (x)) == valof (CSTParser. get_name (parentof (scopeof (x)). expr)) # their names match
466+ scopeof (x) isa Scope && parentof (scopeof (x)) isa Scope && # it has a scope and a parent scope
467+ CSTParser. defines_module (parentof (scopeof (x)). expr) && # the parent scope is a module
468+ valof (CSTParser. get_name (x)) == valof (CSTParser. get_name (parentof (scopeof (x)). expr)) # their names match
469469 seterror! (CSTParser. get_name (x), InvalidModuleName)
470470 end
471471end
@@ -475,7 +475,7 @@ function check_farg_unused(x::EXPR)
475475 if CSTParser. defines_function (x)
476476 sig = CSTParser. rem_wheres_decls (CSTParser. get_sig (x))
477477 if (headof (x) === :function && length (x. args) == 2 && x. args[2 ] isa EXPR && length (x. args[2 ]. args) == 1 && CSTParser. isliteral (x. args[2 ]. args[1 ])) ||
478- (length (x. args) > 1 && headof (x. args[2 ]) === :block && length (x. args[2 ]. args) == 1 && CSTParser. isliteral (x. args[2 ]. args[1 ]))
478+ (length (x. args) > 1 && headof (x. args[2 ]) === :block && length (x. args[2 ]. args) == 1 && CSTParser. isliteral (x. args[2 ]. args[1 ]))
479479 return # Allow functions that return constants
480480 end
481481 if iscall (sig)
@@ -509,12 +509,12 @@ function check_farg_unused_(arg, arg_names)
509509 valof (b. name) isa String && all_underscore (valof (b. name)) && return false
510510
511511 if b === nothing ||
512- # no refs:
512+ # no refs:
513513 isempty (b. refs) ||
514- # only self ref:
514+ # only self ref:
515515 (length (b. refs) == 1 && first (b. refs) == b. name) ||
516- # first usage has binding:
517- (length (b. refs) > 1 && b. refs[2 ] isa EXPR && hasbinding (b. refs[2 ]))
516+ # first usage has binding:
517+ (length (b. refs) > 1 && b. refs[2 ] isa EXPR && hasbinding (b. refs[2 ]))
518518 seterror! (arg, UnusedFunctionArgument)
519519 end
520520
534534
535535function is_nospecialize_call (x)
536536 CSTParser. ismacrocall (x) &&
537- CSTParser. ismacroname (x. args[1 ]) &&
538- is_nospecialize (x. args[1 ])
537+ CSTParser. ismacroname (x. args[1 ]) &&
538+ is_nospecialize (x. args[1 ])
539539end
540540
541541"""
@@ -555,8 +555,8 @@ function collect_hints(x::EXPR, env, missingrefs=:all, isquoted=false, errs=Tupl
555555 push! (errs, (pos, x))
556556 elseif ! isquoted
557557 if missingrefs != :none && isidentifier (x) && ! hasref (x) &&
558- ! (valof (x) == " var" && parentof (x) isa EXPR && isnonstdid (parentof (x))) &&
559- ! ((valof (x) == " stdcall" || valof (x) == " cdecl" || valof (x) == " fastcall" || valof (x) == " thiscall" || valof (x) == " llvmcall" ) && is_in_fexpr (x, x -> iscall (x) && isidentifier (x. args[1 ]) && valof (x. args[1 ]) == " ccall" ))
558+ ! (valof (x) == " var" && parentof (x) isa EXPR && isnonstdid (parentof (x))) &&
559+ ! ((valof (x) == " stdcall" || valof (x) == " cdecl" || valof (x) == " fastcall" || valof (x) == " thiscall" || valof (x) == " llvmcall" ) && is_in_fexpr (x, x -> iscall (x) && isidentifier (x. args[1 ]) && valof (x. args[1 ]) == " ccall" ))
560560
561561 push! (errs, (pos, x))
562562 elseif haserror (x) && errorof (x) isa StaticLint. LintCodes
585585
586586function should_mark_missing_getfield_ref (x, env)
587587 if isidentifier (x) && ! hasref (x) && # x has no ref
588- parentof (x) isa EXPR && headof (parentof (x)) === :quotenode && parentof (parentof (x)) isa EXPR && is_getfield (parentof (parentof (x))) # x is the rhs of a getproperty
588+ parentof (x) isa EXPR && headof (parentof (x)) === :quotenode && parentof (parentof (x)) isa EXPR && is_getfield (parentof (parentof (x))) # x is the rhs of a getproperty
589589 lhsref = refof_maybe_getfield (parentof (parentof (x)). args[1 ])
590590 hasref (x) && return false # We've resolved
591591 if lhsref isa SymbolServer. ModuleStore || (lhsref isa Binding && lhsref. val isa SymbolServer. ModuleStore)
@@ -654,14 +654,14 @@ function is_type_of_call_to_getproperty(x::EXPR)
654654 if iscall (x)
655655 func_name = x. args[1 ]
656656 return (isidentifier (func_name) && valof (func_name) == " getproperty" ) || # getproperty()
657- (is_getfield_w_quotenode (func_name) && isidentifier (func_name. args[2 ]. args[1 ]) && valof (func_name. args[2 ]. args[1 ]) == " getproperty" ) # Base.getproperty()
657+ (is_getfield_w_quotenode (func_name) && isidentifier (func_name. args[2 ]. args[1 ]) && valof (func_name. args[2 ]. args[1 ]) == " getproperty" ) # Base.getproperty()
658658 end
659659 return false
660660 end
661661
662662 return parentof (x) isa EXPR && parentof (parentof (x)) isa EXPR &&
663- ((isdeclaration (parentof (x)) && x === parentof (x). args[2 ] && is_call_to_getproperty (parentof (parentof (x)))) ||
664- (iscurly (parentof (x)) && x === parentof (x). args[1 ] && isdeclaration (parentof (parentof (x))) && parentof (parentof (parentof (x))) isa EXPR && is_call_to_getproperty (parentof (parentof (parentof (x))))))
663+ ((isdeclaration (parentof (x)) && x === parentof (x). args[2 ] && is_call_to_getproperty (parentof (parentof (x)))) ||
664+ (iscurly (parentof (x)) && x === parentof (x). args[1 ] && isdeclaration (parentof (parentof (x))) && parentof (parentof (parentof (x))) isa EXPR && is_call_to_getproperty (parentof (parentof (parentof (x))))))
665665end
666666
667667isunionfaketype (t:: SymbolServer.FakeTypeName ) = t. name. name === :Union && t. name. parent isa SymbolServer. VarRef && t. name. parent. name === :Core
0 commit comments