Sha256: dba43708ac4f19e5cb02e66f6eb07cb27824858dd3a819146fb75c5ff80dc772

Contents?: true

Size: 1.3 KB

Versions: 65

Compression:

Stored size: 1.3 KB

Contents

# 
# Style Fixup Rake Tasks

# 
# Authors:
# * Michael Granger <ged@FaerieMUD.org>
# 


### Coding style checks and fixes
namespace :style do
	
	BLANK_LINE = /^\s*$/
	GOOD_INDENT = /^(\t\s*)?\S/

	# A list of the files that have legitimate leading whitespace, etc.
	PROBLEM_FILES = [ SPECDIR + 'config_spec.rb' ]
	
	desc "Check source files for inconsistent indent and fix them"
	task :fix_indent do
		files = LIB_FILES + SPEC_FILES

		badfiles = Hash.new {|h,k| h[k] = [] }
		
		trace "Checking files for indentation"
		files.each do |file|
			if PROBLEM_FILES.include?( file )
				trace "  skipping problem file #{file}..."
				next
			end
			
			trace "  #{file}"
			linecount = 0
			file.each_line do |line|
				linecount += 1
				
				# Skip blank lines
				next if line =~ BLANK_LINE
				
				# If there's a line with incorrect indent, note it and skip to the 
				# next file
				if line !~ GOOD_INDENT
					trace "    Bad line %d: %p" % [ linecount, line ]
					badfiles[file] << [ linecount, line ]
				end
			end
		end

		if badfiles.empty?
			log "No indentation problems found."
		else
			log "Found incorrect indent in #{badfiles.length} files:\n  "
			badfiles.each do |file, badlines|
				log "  #{file}:\n" +
					"    " + badlines.collect {|badline| "%5d: %p" % badline }.join( "\n    " )
			end
		end
	end

end


Version data entries

65 entries across 65 versions & 14 rubygems

Version Path
vanity-1.7.1 vendor/ruby/1.9.1/gems/pg-0.11.0/rake/style.rb
linguistics-1.0.9 rake/style.rb
markos_linguistics-1.0.8.3 rake/style.rb
pg-0.11.0 rake/style.rb
pg-0.11.0-x86-mswin32 rake/style.rb
pg-0.11.0-x86-mingw32 rake/style.rb
pg-0.11.0pre229 rake/style.rb
pg-0.11.0pre229-x86-mswin32 rake/style.rb
pg-0.11.0pre229-x86-mingw32 rake/style.rb
pg-0.11.0pre220 rake/style.rb
pg-0.10.1 rake/style.rb
bluecloth-2.0.10 rake/style.rb
pg-0.10.1pre209 rake/style.rb
pg-0.10.0 rake/style.rb
linkparser-1.1.0 rake/style.rb
treequel-1.2.0 rake/style.rb
configurability-1.0.4 rake/style.rb
configurability-1.0.3 rake/style.rb
pg-ct-0.10.0 rake/style.rb
pg-jdguyot-0.10.0 rake/style.rb