Sha256: 920753dcba023eb937b087b154db5c6f1a304c23eb9be2135036cc2fd8cd53cb
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
module Pluginscan # Extends Check with helpers for making patterns and ignores based on a list of function names class FunctionCheck < Check def initialize(check_hash) check_hash.default = [] check_hash[:patterns] = self.class.patterns(check_hash[:patterns], check_hash[:function_names]) check_hash[:ignores] = self.class.ignores(check_hash[:ignores], check_hash[:function_names]) super(check_hash) end def self.function_list(functions) # ^ Start of line # [^a-z0-9|_] Characters which would imply that the word isn't the whole function name # \s* any amount of whitespace # \\( a literal open bracket - i.e. the start of the function arguments functions.map{ |function| Regexp.new("(^|[^a-z0-9|_])(#{function})\s*\\(") } end def self.function_ignores(functions) # If the author is creating a similarly named function then that should be ignored (?) functions.map { |function| Regexp.new("function\s+[^a-z0-9|_]?#{function}\s*\\(") } end private def self.patterns(patterns, function_names) Array(patterns) + function_list(function_names) end private def self.ignores(ignores, function_names) Array(ignores) + function_ignores(function_names) + CommentChecker::COMMENT_REGEXPS end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pluginscan-0.9.0 | lib/pluginscan/reports/issues_report/issue_checks/function_check.rb |