From a73dec8a11e57ba7f1e8166a5170bc7eed79bbdb Mon Sep 17 00:00:00 2001 From: Alexandre Bergel Date: Mon, 4 Mar 2024 17:15:14 +0100 Subject: [PATCH] Channel --- src/linting/extended_checks.jl | 4 ++++ test/rai_rules_tests.jl | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/linting/extended_checks.jl b/src/linting/extended_checks.jl index fbd66e5..a195082 100644 --- a/src/linting/extended_checks.jl +++ b/src/linting/extended_checks.jl @@ -67,6 +67,7 @@ struct Threads_Extension <: ExtendedRule end struct Generated_Extension <: ExtendedRule end struct Sync_Extension <: ExtendedRule end struct RemovePage_Extension <: ExtendedRule end +struct Channel_Extension <: ExtendedRule end const all_extended_rule_types = Ref{Any}(InteractiveUtils.subtypes(ExtendedRule)) @@ -196,3 +197,6 @@ function check(::Sync_Extension, x::EXPR) end check(::RemovePage_Extension, x::EXPR) = generic_check(x, "remove_page(hole_variable,hole_variable)") + +check(::Channel_Extension, x::EXPR) = generic_check(x, "Channel(hole_variable_star)") + diff --git a/test/rai_rules_tests.jl b/test/rai_rules_tests.jl index 155a85f..24d93b1 100644 --- a/test/rai_rules_tests.jl +++ b/test/rai_rules_tests.jl @@ -362,7 +362,7 @@ end "Line 18, column 5: `wait` should be used with extreme caution.") end - @testset "fetch, @inbounds, Atomic, Ptr, remove_page" begin + @testset "fetch, @inbounds, Atomic, Ptr, remove_page, Channel" begin source = """ function f() fut = Future{Any}() @@ -390,6 +390,12 @@ end remove_page(pager, pid) end end + + function foo() + ch1 = Channel() + ch2 = Channel(10) + return (ch1, ch2) + end """ @test lint_test(source, "Line 3, column 10: `fetch` should be used with extreme caution.") @@ -402,6 +408,10 @@ end @test lint_test(source, "Line 19, column 22: `Ptr` should be used with extreme caution.") @test lint_test(source, "Line 24, column 9: `remove_page` should be used with extreme caution.") + + @test lint_test(source, "Line 29, column 11: `Channel` should be used with extreme caution.") + @test lint_test(source, "Line 30, column 11: `Channel` should be used with extreme caution.") + end @testset "Array with no specific type 01" begin