-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Try to fix precompile issues for Julia 1.0 * Try to fix some static analysis test cases * Empty `Tuple` method dispatch See documentation on `Vararg` * Fix handling of `Vector` `Vector` has no types ⇒ `length(T.types) == 0` * Remove `try` without `catch` Why was it there to begin with? * basic.jl runs ok Added a heuristic on `lintpkg` to distinguish a package path from a package name. Compat `renamed is_windows`. * Re-write and documentation of `_lintstr` It was *REALLY* hard to understand the intent of the function. The code now is still verbose, but each _code block_ has its specific purpose. Before this we had several stateful variables and conditions that may or may not be triggered * Adjust versions No going back * Using Pkg * `isnull(…)` → `… == nothing` * Remove more `isnull`s and helper function `BROADCAST` * `contains` → `occursin` * Minor code update * `isbits` applies to objects, `isbitstype` to types `t` was supposed to be a type, not an object * Break expression from-string producer code * Use `let …` statements for several reasons ● It's visually easy to distinguish between two different test cases ● Ensures that global state will not change between tests * Colon detection in expression is bad. At least now I know how to fix it * Correctly detect a `:` * Break `guesstype` into multi-dispatch code. This will make testing much easier. Inspired on https://pixorblog.wordpress.com/2018/02/23/julia-dispatch-enum-vs-type-comparison/ (or https://www.juliabloggers.com/julia-dispatching-enum-versus-type/ ) * Fix `guesstype` tests * Remove more `get(…)` calls from version<07's nullables * `contains` → `occursin` * `@lintpragma` seems to be parsed differently now * sed -i s/contains/occursin/g *.jl * forgot that `occursin` has needle as 1st argument 😒 * `--compilecache=no` → `--compiled-modules=no` Per #256 (comment) * Remove `Test` as it belongs to std lib * Simple updates around `get(…)` and `isnull(…)` * Remove `occursin(…)` as they only clog testing now They were meant to test the error being popped, but this was before we had codes for errors. * Base.var → Statistics.var in v1.0 Also, cosmetics * Using another `Base.+` instead of `Base.var` Friendly reminder that Base.var → Statistics.var in v1.0 * Remove `occursin`s * Reformat dict tests * Looks like this test is no longer broken * `Void` → `Cvoid` See JuliaLang/julia#25082 for more context * Remove `occursin` (legacy testing before using codes) * Remove `occursin` * Forward `isknownerror` arguments from `infertype` * Chasing `shadowed variable` problem This error is the root of many tests failing * Drop versions prior to v1.0 * `… ≠ nothing` → `… !== nothing` #256 (comment) * Fix parsing Lines were being parsed _regardless_ of whether they were parsed before. Now the expression _and_ expression offset is being reported to keep track and omit lines already parsed * Mark TODO * Line iterator * Must handle (SubString) indices and not Strings We have to track offsets, so we need indices to the original string. It surprises me that `split(…)` does not return _or_ handle an iterator (forced Array output) * Rewrite test * Offset lines and most of expression iterator Re-wrote `each_line_iterator` so we can actually use it as iterator (with `iterate(…)`) * Inline functions, use offsets as lines * Iterators are hard * Redid the API to have line's offsets The code is made to report expression and line offsets, but I wrapped around those iterators to provide a "just expression" API * Try to replace previous parsing (doesn't work) * Missing try-catch Do mind that pre-compile forced `lintstr` seems to be reporting errors * delete legacy file
- Loading branch information
1 parent
40fa351
commit f9cdca7
Showing
67 changed files
with
958 additions
and
793 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,63 @@ | ||
""" | ||
abstract_eval(ctx::LintContext, ex) :: Nullable | ||
abstract_eval(ctx::LintContext, ex) :: Union{Any, Nothing} | ||
Like `eval`, but does it in the current context and without any dynamism. | ||
Returns `Nullable()` if the result can't be evaluated. | ||
Returns `nothing` if the result can't be evaluated. | ||
""" | ||
abstract_eval(ctx::LintContext, ex::Symbol) = | ||
flatten(BROADCAST(extractobject, lookup(ctx, ex))) | ||
function abstract_eval(ctx::LintContext, ex::Symbol) | ||
let lu = lookup(ctx, ex) | ||
if lu !== nothing | ||
extractobject(lu) | ||
end | ||
end | ||
end | ||
|
||
""" | ||
abstract_eval(ctx::LintContext, ex::Expr) :: Nullable | ||
abstract_eval(ctx::LintContext, ex::Expr) :: Union{Any, Nothing} | ||
If the given expression is curly, and each component of the curly is a constant | ||
object in the given `ctx`, construct the object `x` as would have been done in | ||
the program itself, and return `Nullable(x)`. | ||
the program itself, and return `x`. | ||
Otherwise, if the given expression is `foo.bar`, and `foo` is a standard | ||
library object with attribute `bar`, then construct `foo.bar` as would be done | ||
in the program itself and return it. | ||
Otherwise, return `Nullable()`. | ||
Otherwise, return `nothing`. | ||
""" | ||
abstract_eval(ctx::LintContext, ex::Expr) = begin | ||
if isexpr(ex, :curly) | ||
# TODO: when 0.5 support dropped, remove [...] around ctx | ||
objs = abstract_eval.([ctx], ex.args) | ||
if all(!isnull, objs) | ||
objs = [abstract_eval(ctx, arg) for arg in ex.args] | ||
if all(e->e!==nothing, objs) | ||
try | ||
Nullable(Core.apply_type(get.(objs)...)) | ||
Core.apply_type(objs...) | ||
catch | ||
Nullable() | ||
nothing | ||
end | ||
else | ||
Nullable() | ||
nothing | ||
end | ||
elseif isexpr(ex, :(.)) | ||
head = ex.args[1] | ||
tail = ex.args[2].value | ||
obj = abstract_eval(ctx, head) | ||
if !isnull(obj) | ||
if obj !== nothing | ||
try | ||
Nullable(getfield(get(obj), tail)) | ||
getfield(obj, tail) | ||
catch | ||
Nullable() | ||
nothing | ||
end | ||
else | ||
Nullable() | ||
nothing | ||
end | ||
else | ||
Nullable() | ||
nothing | ||
end | ||
end | ||
|
||
""" | ||
abstract_eval(ctx::LintContext, ex) | ||
Return the literal embedded within a `Nullable{Any}`. | ||
Return the literal embedded within a `Union{Any, Nothing}`. | ||
""" | ||
abstract_eval(ctx::LintContext, ex) = lexicalvalue(ex) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.