diff --git a/lib/cc/engine/analyzers/php/main.rb b/lib/cc/engine/analyzers/php/main.rb index 8237ca88..052506cf 100644 --- a/lib/cc/engine/analyzers/php/main.rb +++ b/lib/cc/engine/analyzers/php/main.rb @@ -15,6 +15,9 @@ class Main < CC::Engine::Analyzers::Base "**/*.php", ].freeze DEFAULT_MASS_THRESHOLD = 28 + DEFAULT_FILTERS = [ + "(use ___)".freeze, + ].freeze POINTS_PER_OVERAGE = 100_000 def transform_sexp(sexp) @@ -32,6 +35,10 @@ def process_file(path) def php_parser ::CC::Engine::Analyzers::Php::Parser end + + def default_filters + DEFAULT_FILTERS.map { |filter| Sexp::Matcher.parse filter } + end end end end diff --git a/spec/cc/engine/analyzers/php/main_spec.rb b/spec/cc/engine/analyzers/php/main_spec.rb index 008b33b0..1f2c5b03 100644 --- a/spec/cc/engine/analyzers/php/main_spec.rb +++ b/spec/cc/engine/analyzers/php/main_spec.rb @@ -163,6 +163,37 @@ "lines" => { "begin" => 11, "end" => 16 }, }) end + + it "ignores namespace and use declarations" do + create_source_file("foo.php", <<~EOPHP) +