Skip to content

Large file limits for linting #333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/StaticLint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ include("scope.jl")
include("subtypes.jl")
include("methodmatching.jl")

const LARGE_FILE_LIMIT = 1_000_000 # bytes

mutable struct Meta
binding::Union{Nothing,Binding}
scope::Union{Nothing,Scope}
Expand Down Expand Up @@ -277,8 +279,13 @@ function followinclude(x, state::State)
seterror!(x, IncludeLoop)
return
end
f = getfile(state.server, path)
if f.cst.fullspan > LARGE_FILE_LIMIT
seterror!(x, FileTooBig)
return
end
oldfile = state.file
state.file = getfile(state.server, path)
state.file = f
push!(state.included_files, getpath(state.file))
setroot(state.file, getroot(oldfile))
setscope!(getcst(state.file), nothing)
Expand Down
8 changes: 4 additions & 4 deletions src/linting/checks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ UnsupportedConstLocalVariable,
UnassignedKeywordArgument,
CannotDefineFuncAlreadyHasValue,
DuplicateFuncArgName,
IncludePathContainsNULL)


IncludePathContainsNULL,
FileTooBig)

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

haserror(m::Meta) = m.error !== nothing
Expand Down