Sha256: 1c5e9aa5199b344e36bee3fdca23afe34843aff9f367ba437153418a72af8521
Contents?: true
Size: 788 Bytes
Versions: 23
Compression:
Stored size: 788 Bytes
Contents
# encoding: utf-8 module RuboCop module Cop module Style # This cop makes sure that Ruby source files have snake_case names. class FileName < Cop MSG = 'Use snake_case for source file names.' SNAKE_CASE = /^[\da-z_]+$/ def investigate(processed_source) file_path = processed_source.buffer.name return if config.file_to_include?(file_path) basename = File.basename(file_path).sub(/\.[^\.]+$/, '') return if snake_case?(basename) range = source_range(processed_source.buffer, 1, 0) add_offense(nil, range) end private def snake_case?(basename) basename.split('.').all? { |fragment| fragment =~ SNAKE_CASE } end end end end end
Version data entries
23 entries across 23 versions & 2 rubygems