Sha256: c332401dbe4d6ad34d6dd25429d13acffa8a012ef89faed61327e2bfbecfdf98
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
require_relative '../classes/error' module NamingChecker def self.check_naming_res(error_bin, path) bad_named_lines = check_naming(path) bad_named_lines.each { |line| error_bin << line if bad_named_lines } error_bin end private_class_method def self.raise_err(line, err_type, path_name) error = Error.new(line, err_type, path_name) naming_err = error.print_err(line, err_type, path_name) if error naming_err end def self.bad_var_case(bad_case) bad_var_start = /(var|let|const|[\s])[\s]*([[:upper:]]{1,}|\d)+(([\w]+[\s][\w]+)|[\w]+)[\s]*[\=][\s]*[\w]*/ bad_var_start.match?(bad_case) end def self.check_naming(fpath) bad_lines = [] check_line = lambda { |line| line_with_bad_naming = line if bad_var_case(line.content) bad_lines << line_with_bad_naming.number if line_with_bad_naming } err_type = 'VAR_NAMING_ERR' fpath.lines.each(&check_line) bad_lines.each { |line| raise_err(line, err_type, fpath.filename) if !bad_lines.empty? } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jscop-0.1.3 | lib/jscop/naming_checker.rb |
jscop-0.1.2 | lib/jscop/naming_checker.rb |