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

Filtering on commit change #42

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
8 changes: 5 additions & 3 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ function run_lint(
server = global_server,
io::IO=stdout,
filters::Vector{LintCodes}=essential_filters,
formatter::AbstractFormatter=PlainFormat()
formatter::AbstractFormatter=PlainFormat(),
lines_to_reports_as_json::String="""{}"""
)
# If we are running Lint on a directory
isdir(rootpath) && return _run_lint_on_dir(rootpath; server, io, filters, formatter)
Expand Down Expand Up @@ -302,7 +303,8 @@ function run_lint_on_text(
io::IO=stdout,
filters::Vector{LintCodes}=essential_filters,
formatter::AbstractFormatter=PlainFormat(),
directory::String = "" # temporary directory to be created. If empty, let Julia decide
directory::String = "", # temporary directory to be created. If empty, let Julia decide
lines_to_reports_as_json::String="{}"
)
local tmp_file_name, tmp_dir
local correct_directory = ""
Expand All @@ -317,7 +319,7 @@ function run_lint_on_text(
open(tmp_file_name, "w") do file
write(file, source)
flush(file)
run_lint(tmp_file_name; server, io, filters, formatter)
run_lint(tmp_file_name; server, io, filters, formatter, lines_to_reports_as_json)
end

# If a directory has been provided, then it needs to be deleted, after manually deleting the file
Expand Down
16 changes: 16 additions & 0 deletions test/rai_rules_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,22 @@ end
@test !should_be_filtered(hint_as_string2, filters)
end

@testset "Filtering on lines of files" begin
source = """
function f()
@async 1 + 1
@async 1 + 1
@async 1 + 1
@async 1 + 1
@async 1 + 1
@async 1 + 1
@async 1 + 1
end
"""
isdefined(Main, :Infiltrator) && Main.infiltrate(@__MODULE__, Base.@locals, @__FILE__, @__LINE__)
@test lint_test(source, """fdfds""")
end

@testset "Fetching values from AST" begin
@test fetch_value(CSTParser.parse("f"), :IDENTIFIER) == "f"
@test fetch_value(CSTParser.parse("f()"), :IDENTIFIER) == "f"
Expand Down
Loading