Skip to content

Commit

Permalink
Improve check_snake_case_filename check in msftidy
Browse files Browse the repository at this point in the history
We also remove the separator, since the file is basenamed.
  • Loading branch information
wvu committed Oct 5, 2018
1 parent eb0febc commit 05ac387
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/dev/msftidy.rb
Expand Up @@ -254,11 +254,11 @@ def line_has_require?(line, lib)
line =~ /^\s*(require|load)\s+['"]#{lib}['"]/
end

# This check also enforces namespace module name reversibility
def check_snake_case_filename
sep = File::SEPARATOR
good_name = Regexp.new "^[a-z0-9_#{sep}]+\.rb$"
unless @name =~ good_name
warn "Filenames should be alphanum and snake case."
# TODO: Can we add the __ check to the look{ahead,behind}?
if @name !~ /^(?!_)[a-z0-9_]+(?<!_)\.rb$/ || @name.include?('__')
warn('Filenames should be lowercase alphanumeric snake case.')
end
end

Expand Down

0 comments on commit 05ac387

Please sign in to comment.