Skip to content
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

Making Lint easy to run #11

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions scripts/run_julia_lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ julia --project=$RELINTPATH -e "
@info \"Running lint on \$(length(all_files)) files\"

formatter = ReLint.PreCommitFormat()
# context = LintContext([\"LogStatementsMustBeSafe\"])
context = LintContext($RULE)
@info \"context\" context
@info \"Running $(length(context)) rules on $(length(all_files)) files and folders\"

# Run lint on all files
for f in all_files
Expand Down
5 changes: 1 addition & 4 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,11 @@ end
print_footer(::PreCommitFormat, io::IO) = nothing
function print_summary(::PreCommitFormat, io::IO, result::LintResult)
print_summary(PlainFormat(), io, result)
printstyled(io, "Note that the list above only show fatal violations\n", color=:red)
end

function print_report(::PreCommitFormat, io::IO, lint_report::LintRuleReport, result::LintResult)
should_print_report(result) || return
# Do not print anything if it is not a fatal violation
lint_report.rule isa FatalLintRule || return

printstyled(io, "Line $(lint_report.line), column $(lint_report.column):", color=:green)
print(io, " ")
print(io, lint_report.msg)
Expand Down Expand Up @@ -281,7 +279,6 @@ function print_report(::PlainFormat, io::IO, lint_report::LintRuleReport, result
print(io, " ")
println(io, lint_report.file)
result.printout_count += 1

end

function print_summary(
Expand Down
3 changes: 2 additions & 1 deletion test/rai_rules_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1883,9 +1883,10 @@ end

expected = r"""
Line 3, column 3: Unsafe logging statement\. You must enclose variables and strings with `@safe\(\.\.\.\)`\. \H+/bar.jl
Line 2, column 3: Use `@spawn` instead of `@async`. \H+/bar.jl
Line 3, column 3: Unsafe logging statement\. You must enclose variables and strings with `@safe\(\.\.\.\)`\. \H+/foo.jl
Line 2, column 3: Use `@spawn` instead of `@async`. \H+/foo.jl
4 potential threats are found: 2 fatal violations, 2 violations and 0 recommendation
Note that the list above only show fatal violations
"""
result_matching = !isnothing(match(expected, result))
end
Expand Down