Skip to content

Commit 7f99103

Browse files
committed
Large file limits for linting
1 parent 06d008e commit 7f99103

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/StaticLint.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ include("scope.jl")
1717
include("subtypes.jl")
1818
include("methodmatching.jl")
1919

20+
const LARGE_FILE_LIMIT = 1_000_000 # bytes
21+
2022
mutable struct Meta
2123
binding::Union{Nothing,Binding}
2224
scope::Union{Nothing,Scope}
@@ -277,8 +279,13 @@ function followinclude(x, state::State)
277279
seterror!(x, IncludeLoop)
278280
return
279281
end
282+
f = getfile(state.server, path)
283+
if f.cst.fullspan > LARGE_FILE_LIMIT
284+
seterror!(x, FileTooBig)
285+
return
286+
end
280287
oldfile = state.file
281-
state.file = getfile(state.server, path)
288+
state.file = f
282289
push!(state.included_files, getpath(state.file))
283290
setroot(state.file, getroot(oldfile))
284291
setscope!(getcst(state.file), nothing)

src/linting/checks.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ UnsupportedConstLocalVariable,
2727
UnassignedKeywordArgument,
2828
CannotDefineFuncAlreadyHasValue,
2929
DuplicateFuncArgName,
30-
IncludePathContainsNULL)
31-
32-
30+
IncludePathContainsNULL,
31+
FileTooBig)
3332

3433
const LintCodeDescriptions = Dict{LintCodes,String}(IncorrectCallArgs => "Possible method call error.",
3534
IncorrectIterSpec => "A loop iterator has been used that will likely error.",
@@ -58,7 +57,8 @@ const LintCodeDescriptions = Dict{LintCodes,String}(IncorrectCallArgs => "Possib
5857
UnassignedKeywordArgument => "Keyword argument not assigned.",
5958
CannotDefineFuncAlreadyHasValue => "Cannot define function ; it already has a value.",
6059
DuplicateFuncArgName => "Function argument name not unique.",
61-
IncludePathContainsNULL => "Cannot include file, path cotains NULL characters."
60+
IncludePathContainsNULL => "Cannot include file, path cotains NULL characters.",
61+
FileTooBig => "File too big, not following include."
6262
)
6363

6464
haserror(m::Meta) = m.error !== nothing

0 commit comments

Comments
 (0)