From c8e05cfd3756086cb25bb34ea414c5c05d7b7199 Mon Sep 17 00:00:00 2001 From: Alexandre Bergel Date: Mon, 24 Jun 2024 10:12:30 +0200 Subject: [PATCH] very early draft... --- src/interface.jl | 8 +++++--- test/rai_rules_tests.jl | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/interface.jl b/src/interface.jl index 86dc56e..8f1dd96 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -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) @@ -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 = "" @@ -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 diff --git a/test/rai_rules_tests.jl b/test/rai_rules_tests.jl index 79380b9..8eaa0c6 100644 --- a/test/rai_rules_tests.jl +++ b/test/rai_rules_tests.jl @@ -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"