Rubocop: Low hanging fruit
This commit is contained in:
		
							parent
							
								
									e02049727b
								
							
						
					
					
						commit
						a8d27e5788
					
				
							
								
								
									
										23
									
								
								.rubocop.yml
								
								
								
								
							
							
						
						
									
										23
									
								
								.rubocop.yml
								
								
								
								
							|  | @ -7,51 +7,28 @@ AllCops: | |||
|   - lib/jekyll/collection.rb | ||||
|   - lib/jekyll/command.rb | ||||
|   - lib/jekyll/configuration.rb | ||||
|   - lib/jekyll/converter.rb | ||||
|   - lib/jekyll/converters/identity.rb | ||||
|   - lib/jekyll/converters/markdown | ||||
|   - lib/jekyll/converters/markdown/kramdown_parser.rb | ||||
|   - lib/jekyll/converters/markdown/rdiscount_parser.rb | ||||
|   - lib/jekyll/converters/markdown/redcarpet_parser.rb | ||||
|   - lib/jekyll/converters/markdown.rb | ||||
|   - lib/jekyll/converters/smartypants.rb | ||||
|   - lib/jekyll/convertible.rb | ||||
|   - lib/jekyll/deprecator.rb | ||||
|   - lib/jekyll/document.rb | ||||
|   - lib/jekyll/drops/collection_drop.rb | ||||
|   - lib/jekyll/drops/document_drop.rb | ||||
|   - lib/jekyll/drops/drop.rb | ||||
|   - lib/jekyll/drops/jekyll_drop.rb | ||||
|   - lib/jekyll/drops/site_drop.rb | ||||
|   - lib/jekyll/drops/unified_payload_drop.rb | ||||
|   - lib/jekyll/drops/url_drop.rb | ||||
|   - lib/jekyll/entry_filter.rb | ||||
|   - lib/jekyll/errors.rb | ||||
|   - lib/jekyll/excerpt.rb | ||||
|   - lib/jekyll/external.rb | ||||
|   - lib/jekyll/filters.rb | ||||
|   - lib/jekyll/frontmatter_defaults.rb | ||||
|   - lib/jekyll/generator.rb | ||||
|   - lib/jekyll/hooks.rb | ||||
|   - lib/jekyll/layout.rb | ||||
|   - lib/jekyll/liquid_extensions.rb | ||||
|   - lib/jekyll/liquid_renderer/file.rb | ||||
|   - lib/jekyll/liquid_renderer/table.rb | ||||
|   - lib/jekyll/liquid_renderer.rb | ||||
|   - lib/jekyll/log_adapter.rb | ||||
|   - lib/jekyll/page.rb | ||||
|   - lib/jekyll/plugin.rb | ||||
|   - lib/jekyll/plugin_manager.rb | ||||
|   - lib/jekyll/publisher.rb | ||||
|   - lib/jekyll/reader.rb | ||||
|   - lib/jekyll/readers/collection_reader.rb | ||||
|   - lib/jekyll/readers/data_reader.rb | ||||
|   - lib/jekyll/readers/layout_reader.rb | ||||
|   - lib/jekyll/readers/page_reader.rb | ||||
|   - lib/jekyll/readers/post_reader.rb | ||||
|   - lib/jekyll/readers/static_file_reader.rb | ||||
|   - lib/jekyll/regenerator.rb | ||||
|   - lib/jekyll/related_posts.rb | ||||
|   - lib/jekyll/renderer.rb | ||||
|   - lib/jekyll/site.rb | ||||
|   - lib/jekyll/static_file.rb | ||||
|  |  | |||
|  | @ -5,14 +5,14 @@ module Jekyll | |||
|         def initialize(config) | ||||
|           Jekyll::External.require_with_graceful_fail "rdiscount" | ||||
|           @config = config | ||||
|           @rdiscount_extensions = @config['rdiscount']['extensions'].map(&:to_sym) | ||||
|           @rdiscount_extensions = @config["rdiscount"]["extensions"].map(&:to_sym) | ||||
|         end | ||||
| 
 | ||||
|         def convert(content) | ||||
|           rd = RDiscount.new(content, *@rdiscount_extensions) | ||||
|           html = rd.to_html | ||||
|           if @config['rdiscount']['toc_token'] | ||||
|             html = replace_generated_toc(rd, html, @config['rdiscount']['toc_token']) | ||||
|           if @config["rdiscount"]["toc_token"] | ||||
|             html = replace_generated_toc(rd, html, @config["rdiscount"]["toc_token"]) | ||||
|           end | ||||
|           html | ||||
|         end | ||||
|  | @ -21,7 +21,7 @@ module Jekyll | |||
|         def replace_generated_toc(rd, html, toc_token) | ||||
|           if rd.generate_toc && html.include?(toc_token) | ||||
|             utf8_toc = rd.toc_content | ||||
|             utf8_toc.force_encoding('utf-8') if utf8_toc.respond_to?(:force_encoding) | ||||
|             utf8_toc.force_encoding("utf-8") if utf8_toc.respond_to?(:force_encoding) | ||||
|             html.gsub(toc_token, utf8_toc) | ||||
|           else | ||||
|             html | ||||
|  |  | |||
|  | @ -17,13 +17,13 @@ module Jekyll | |||
|       end | ||||
| 
 | ||||
|       def excerpt | ||||
|         fallback_data['excerpt'].to_s | ||||
|         fallback_data["excerpt"].to_s | ||||
|       end | ||||
| 
 | ||||
|       def <=>(other) | ||||
|         return nil unless other.is_a? DocumentDrop | ||||
|         cmp = self['date'] <=> other['date'] | ||||
|         cmp = self['path'] <=> other['path'] if cmp.nil? || cmp == 0 | ||||
|         cmp = self["date"] <=> other["date"] | ||||
|         cmp = self["path"] <=> other["path"] if cmp.nil? || cmp == 0 | ||||
|         cmp | ||||
|       end | ||||
| 
 | ||||
|  |  | |||
|  | @ -13,10 +13,10 @@ module Jekyll | |||
|       # | ||||
|       # Returns the mutability of the class | ||||
|       def self.mutable(is_mutable = nil) | ||||
|         if is_mutable | ||||
|           @is_mutable = is_mutable | ||||
|         @is_mutable = if is_mutable | ||||
|                         is_mutable | ||||
|                       else | ||||
|           @is_mutable = false | ||||
|                         false | ||||
|                       end | ||||
|       end | ||||
| 
 | ||||
|  | @ -134,7 +134,7 @@ module Jekyll | |||
|       # | ||||
|       # Returns a pretty generation of the hash representation of the Drop. | ||||
|       def inspect | ||||
|         require 'json' | ||||
|         require "json" | ||||
|         JSON.pretty_generate to_h | ||||
|       end | ||||
| 
 | ||||
|  |  | |||
|  | @ -19,20 +19,20 @@ module Jekyll | |||
|       end | ||||
| 
 | ||||
|       def title | ||||
|         Utils.slugify(@obj.data['slug'], :mode => "pretty", :cased => true) || | ||||
|         Utils.slugify(@obj.data["slug"], :mode => "pretty", :cased => true) || | ||||
|           Utils.slugify(@obj.basename_without_ext, :mode => "pretty", :cased => true) | ||||
|       end | ||||
| 
 | ||||
|       def slug | ||||
|         Utils.slugify(@obj.data['slug']) || Utils.slugify(@obj.basename_without_ext) | ||||
|         Utils.slugify(@obj.data["slug"]) || Utils.slugify(@obj.basename_without_ext) | ||||
|       end | ||||
| 
 | ||||
|       def categories | ||||
|         category_set = Set.new | ||||
|         Array(@obj.data['categories']).each do |category| | ||||
|         Array(@obj.data["categories"]).each do |category| | ||||
|           category_set << category.to_s.downcase | ||||
|         end | ||||
|         category_set.to_a.join('/') | ||||
|         category_set.to_a.join("/") | ||||
|       end | ||||
| 
 | ||||
|       def year | ||||
|  |  | |||
|  | @ -59,9 +59,9 @@ module Jekyll | |||
|     end | ||||
| 
 | ||||
|     def to_liquid | ||||
|       doc.data['excerpt'] = nil | ||||
|       doc.data["excerpt"] = nil | ||||
|       @to_liquid ||= doc.to_liquid | ||||
|       doc.data['excerpt'] = self | ||||
|       doc.data["excerpt"] = self | ||||
|       @to_liquid | ||||
|     end | ||||
| 
 | ||||
|  |  | |||
|  | @ -23,7 +23,7 @@ module Jekyll | |||
|             require name | ||||
|           rescue LoadError | ||||
|             Jekyll.logger.debug "Couldn't load #{name}. Skipping." | ||||
|             block.call(name) if block | ||||
|             yield(name) if block | ||||
|             false | ||||
|           end | ||||
|         end | ||||
|  | @ -39,7 +39,7 @@ module Jekyll | |||
|       def require_with_graceful_fail(names) | ||||
|         Array(names).each do |name| | ||||
|           begin | ||||
|             Jekyll.logger.debug "Requiring:", "#{name}" | ||||
|             Jekyll.logger.debug "Requiring:", name.to_s | ||||
|             require name | ||||
|           rescue LoadError => e | ||||
|             Jekyll.logger.error "Dependency Error:", <<-MSG | ||||
|  | @ -50,7 +50,7 @@ The full error message from Ruby is: '#{e.message}' | |||
| 
 | ||||
| If you run into trouble, you can find helpful resources at http://jekyllrb.com/help/! | ||||
|             MSG | ||||
|             raise Jekyll::Errors::MissingDependencyException.new(name) | ||||
|             raise Jekyll::Errors::MissingDependencyException, name | ||||
|           end | ||||
|         end | ||||
|       end | ||||
|  |  | |||
|  | @ -8,7 +8,7 @@ module Jekyll | |||
| 
 | ||||
|       def parse(content) | ||||
|         measure_time do | ||||
|           @template = Liquid::Template.parse(content, line_numbers: true) | ||||
|           @template = Liquid::Template.parse(content, :line_numbers => true) | ||||
|         end | ||||
| 
 | ||||
|         self | ||||
|  |  | |||
|  | @ -7,7 +7,7 @@ module Jekyll | |||
|       :info  => ::Logger::INFO, | ||||
|       :warn  => ::Logger::WARN, | ||||
|       :error => ::Logger::ERROR | ||||
|     } | ||||
|     }.freeze | ||||
| 
 | ||||
|     # Public: Create a new instance of a log writer | ||||
|     # | ||||
|  | @ -98,7 +98,7 @@ module Jekyll | |||
|     # | ||||
|     # Returns the formatted message | ||||
|     def message(topic, message) | ||||
|       msg = formatted_topic(topic) + message.to_s.gsub(/\s+/, ' ') | ||||
|       msg = formatted_topic(topic) + message.to_s.gsub(/\s+/, " ") | ||||
|       messages << msg | ||||
|       msg | ||||
|     end | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ module Jekyll | |||
|       :lowest  => -100, | ||||
|       :normal  => 0, | ||||
|       :high    => 10 | ||||
|     } | ||||
|     }.freeze | ||||
| 
 | ||||
|     # | ||||
| 
 | ||||
|  |  | |||
|  | @ -15,7 +15,7 @@ module Jekyll | |||
|     private | ||||
| 
 | ||||
|     def can_be_published?(thing) | ||||
|       thing.data.fetch('published', true) || @site.unpublished | ||||
|       thing.data.fetch("published", true) || @site.unpublished | ||||
|     end | ||||
|   end | ||||
| end | ||||
|  |  | |||
|  | @ -30,14 +30,14 @@ module Jekyll | |||
|       return unless File.directory?(dir) && !@entry_filter.symlink?(dir) | ||||
| 
 | ||||
|       entries = Dir.chdir(dir) do | ||||
|         Dir['*.{yaml,yml,json,csv}'] + Dir['*'].select { |fn| File.directory?(fn) } | ||||
|         Dir["*.{yaml,yml,json,csv}"] + Dir["*"].select { |fn| File.directory?(fn) } | ||||
|       end | ||||
| 
 | ||||
|       entries.each do |entry| | ||||
|         path = @site.in_source_dir(dir, entry) | ||||
|         next if @entry_filter.symlink?(path) | ||||
| 
 | ||||
|         key = sanitize_filename(File.basename(entry, '.*')) | ||||
|         key = sanitize_filename(File.basename(entry, ".*")) | ||||
|         if File.directory?(path) | ||||
|           read_data_to(path, data[key] = {}) | ||||
|         else | ||||
|  | @ -51,10 +51,10 @@ module Jekyll | |||
|     # Returns the contents of the data file. | ||||
|     def read_data_file(path) | ||||
|       case File.extname(path).downcase | ||||
|       when '.csv' | ||||
|       when ".csv" | ||||
|         CSV.read(path, { | ||||
|           :headers  => true, | ||||
|                          :encoding => site.config['encoding'] | ||||
|           :encoding => site.config["encoding"] | ||||
|         }).map(&:to_hash) | ||||
|       else | ||||
|         SafeYAML.load_file(path) | ||||
|  | @ -62,9 +62,9 @@ module Jekyll | |||
|     end | ||||
| 
 | ||||
|     def sanitize_filename(name) | ||||
|       name.gsub!(/[^\w\s-]+/, '') | ||||
|       name.gsub!(/[^\w\s-]+/, "") | ||||
|       name.gsub!(/(^|\b\s)\s+($|\s?\b)/, '\\1\\2') | ||||
|       name.gsub(/\s+/, '_') | ||||
|       name.gsub(/\s+/, "_") | ||||
|     end | ||||
|   end | ||||
| end | ||||
|  |  | |||
|  | @ -9,7 +9,7 @@ module Jekyll | |||
|     def initialize(post) | ||||
|       @post = post | ||||
|       @site = post.site | ||||
|       Jekyll::External.require_with_graceful_fail('classifier-reborn') if site.lsi | ||||
|       Jekyll::External.require_with_graceful_fail("classifier-reborn") if site.lsi | ||||
|     end | ||||
| 
 | ||||
|     def build | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue