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 )
457457
458458function check_modulename (x:: EXPR )
459459 if CSTParser. defines_module (x) && # x is a module
460- scopeof (x) isa Scope && parentof (scopeof (x)) isa Scope && # it has a scope and a parent scope
461- CSTParser. defines_module (parentof (scopeof (x)). expr) && # the parent scope is a module
462- valof (CSTParser. get_name (x)) == valof (CSTParser. get_name (parentof (scopeof (x)). expr)) # their names match
460+ scopeof (x) isa Scope && parentof (scopeof (x)) isa Scope && # it has a scope and a parent scope
461+ CSTParser. defines_module (parentof (scopeof (x)). expr) && # the parent scope is a module
462+ valof (CSTParser. get_name (x)) == valof (CSTParser. get_name (parentof (scopeof (x)). expr)) # their names match
463463 seterror! (CSTParser. get_name (x), InvalidModuleName)
464464 end
465465end
@@ -469,7 +469,7 @@ function check_farg_unused(x::EXPR)
469469 if CSTParser. defines_function (x)
470470 sig = CSTParser. rem_wheres_decls (CSTParser. get_sig (x))
471471 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 ])) ||
472- (length (x. args) > 1 && headof (x. args[2 ]) === :block && length (x. args[2 ]. args) == 1 && CSTParser. isliteral (x. args[2 ]. args[1 ]))
472+ (length (x. args) > 1 && headof (x. args[2 ]) === :block && length (x. args[2 ]. args) == 1 && CSTParser. isliteral (x. args[2 ]. args[1 ]))
473473 return # Allow functions that return constants
474474 end
475475 if iscall (sig)
@@ -503,12 +503,12 @@ function check_farg_unused_(arg, arg_names)
503503 valof (b. name) isa String && all_underscore (valof (b. name)) && return false
504504
505505 if b === nothing ||
506- # no refs:
506+ # no refs:
507507 isempty (b. refs) ||
508- # only self ref:
508+ # only self ref:
509509 (length (b. refs) == 1 && first (b. refs) == b. name) ||
510- # first usage has binding:
511- (length (b. refs) > 1 && b. refs[2 ] isa EXPR && hasbinding (b. refs[2 ]))
510+ # first usage has binding:
511+ (length (b. refs) > 1 && b. refs[2 ] isa EXPR && hasbinding (b. refs[2 ]))
512512 seterror! (arg, UnusedFunctionArgument)
513513 end
514514
528528
529529function is_nospecialize_call (x)
530530 CSTParser. ismacrocall (x) &&
531- CSTParser. ismacroname (x. args[1 ]) &&
532- is_nospecialize (x. args[1 ])
531+ CSTParser. ismacroname (x. args[1 ]) &&
532+ is_nospecialize (x. args[1 ])
533533end
534534
535535"""
@@ -538,7 +538,7 @@ collect_hints(x::EXPR, env, missingrefs = :all, isquoted = false, errs = Tuple{I
538538Collect hints and errors from an expression. `missingrefs` = (:none, :id, :all) determines whether unresolved
539539identifiers are marked, the :all option will mark identifiers used in getfield calls."
540540"""
541- function collect_hints (x:: EXPR , env, missingrefs= :all , isquoted= false , errs= Tuple{Int,EXPR}[], pos= 0 )
541+ function collect_hints (x:: EXPR , env, missingrefs = :all , isquoted = false , errs = Tuple{Int,EXPR}[], pos = 0 )
542542 if quoted (x)
543543 isquoted = true
544544 elseif isquoted && unquoted (x)
@@ -549,8 +549,8 @@ function collect_hints(x::EXPR, env, missingrefs=:all, isquoted=false, errs=Tupl
549549 push! (errs, (pos, x))
550550 elseif ! isquoted
551551 if missingrefs != :none && isidentifier (x) && ! hasref (x) &&
552- ! (valof (x) == " var" && parentof (x) isa EXPR && isnonstdid (parentof (x))) &&
553- ! ((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" ))
552+ ! (valof (x) == " var" && parentof (x) isa EXPR && isnonstdid (parentof (x))) &&
553+ ! ((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" ))
554554
555555 push! (errs, (pos, x))
556556 elseif haserror (x) && errorof (x) isa StaticLint. LintCodes
579579
580580function should_mark_missing_getfield_ref (x, env)
581581 if isidentifier (x) && ! hasref (x) && # x has no ref
582- 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
582+ 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
583583 lhsref = refof_maybe_getfield (parentof (parentof (x)). args[1 ])
584584 hasref (x) && return false # We've resolved
585585 if lhsref isa SymbolServer. ModuleStore || (lhsref isa Binding && lhsref. val isa SymbolServer. ModuleStore)
@@ -648,14 +648,14 @@ function is_type_of_call_to_getproperty(x::EXPR)
648648 if iscall (x)
649649 func_name = x. args[1 ]
650650 return (isidentifier (func_name) && valof (func_name) == " getproperty" ) || # getproperty()
651- (is_getfield_w_quotenode (func_name) && isidentifier (func_name. args[2 ]. args[1 ]) && valof (func_name. args[2 ]. args[1 ]) == " getproperty" ) # Base.getproperty()
651+ (is_getfield_w_quotenode (func_name) && isidentifier (func_name. args[2 ]. args[1 ]) && valof (func_name. args[2 ]. args[1 ]) == " getproperty" ) # Base.getproperty()
652652 end
653653 return false
654654 end
655655
656656 return parentof (x) isa EXPR && parentof (parentof (x)) isa EXPR &&
657- ((isdeclaration (parentof (x)) && x === parentof (x). args[2 ] && is_call_to_getproperty (parentof (parentof (x)))) ||
658- (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))))))
657+ ((isdeclaration (parentof (x)) && x === parentof (x). args[2 ] && is_call_to_getproperty (parentof (parentof (x)))) ||
658+ (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))))))
659659end
660660
661661isunionfaketype (t:: SymbolServer.FakeTypeName ) = t. name. name === :Union && t. name. parent isa SymbolServer. VarRef && t. name. parent. name === :Core
765765
766766# find any parent nodes that are :if blocks and a pseudo-index of which branch
767767# x is in
768- function find_if_parents (x:: EXPR , current= Int[], list= Dict {EXPR,Vector{Int}} ())
768+ function find_if_parents (x:: EXPR , current = Int[], list = Dict {EXPR,Vector{Int}} ())
769769 if x. head in (:block , :elseif ) && parentof (x) isa EXPR && headof (parentof (x)) in (:if , :elseif )
770770 i = 1
771771 while i <= length (parentof (x). args)
0 commit comments