diff --git a/.rubocop.yml b/.rubocop.yml index f94395cd..ce750ace 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -57,8 +57,6 @@ Lint/UnneededRequireStatement: Enabled: false Lint/UnreachableCode: Severity: error -Lint/UselessAccessModifier: - Enabled: false Lint/Void: Enabled: false Metrics/AbcSize: diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index bdfa4b86..5f2aa12a 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -207,16 +207,12 @@ module Jekyll @container ||= site.config["collections_dir"] end - private - def read_document(full_path) doc = Document.new(full_path, :site => site, :collection => self) doc.read docs << doc unless doc.data["published"] == false end - private - def read_static_file(file_path, full_path) relative_dir = Jekyll.sanitized_path( relative_directory, diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index efdaea67..9b8417cd 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -103,6 +103,7 @@ module Jekyll # Perform logical validation of CLI options private + def validate_options(opts) if opts["livereload"] if opts["detach"] @@ -131,9 +132,6 @@ module Jekyll end end - # - - private # rubocop:disable Metrics/AbcSize def register_reload_hooks(opts) require_relative "serve/live_reload_reactor" @@ -171,7 +169,6 @@ module Jekyll # when we get ready to party, checking for an setting up an error page # and making sure our destination exists. - private def setup(destination) require_relative "serve/servlet" @@ -186,9 +183,6 @@ module Jekyll end end - # - - private def webrick_opts(opts) opts = { :JekyllOptions => opts, @@ -209,9 +203,6 @@ module Jekyll opts end - # - - private def start_up_webrick(opts, destination) if opts["livereload"] @reload_reactor.start(opts) @@ -226,8 +217,6 @@ module Jekyll end # Recreate NondisclosureName under utf-8 circumstance - - private def file_handler_opts WEBrick::Config::FileHandler.merge({ :FancyIndexing => true, @@ -237,9 +226,6 @@ module Jekyll }) end - # - - private def server_address(server, options = {}) format_url( server.config[:SSLEnable], @@ -249,7 +235,6 @@ module Jekyll ) end - private def format_url(ssl_enabled, address, port, baseurl = nil) format("%s://%
s:%i%s", { :prefix => ssl_enabled ? "https" : "http", @@ -259,9 +244,6 @@ module Jekyll }) end - # - - private def default_url(opts) config = configuration_from_options(opts) format_url( @@ -271,9 +253,6 @@ module Jekyll ) end - # - - private def launch_browser(server, opts) address = server_address(server, opts) return system "start", address if Utils::Platforms.windows? @@ -286,8 +265,6 @@ module Jekyll # Keep in our area with a thread or detach the server as requested # by the user. This method determines what we do based on what you # ask us to do. - - private def boot_or_detach(server, opts) if opts["detach"] pid = Process.fork do @@ -305,8 +282,6 @@ module Jekyll end # Make the stack verbose if the user requests it. - - private def enable_logging(opts) opts[:AccessLog] = [] level = WEBrick::Log.const_get(opts[:JekyllOptions]["verbose"] ? :DEBUG : :WARN) @@ -316,8 +291,6 @@ module Jekyll # Add SSL to the stack if the user triggers --enable-ssl and they # provide both types of certificates commonly needed. Raise if they # forget to add one of the certificates. - - private def enable_ssl(opts) cert, key, src = opts[:JekyllOptions].values_at("ssl_cert", "ssl_key", "source") @@ -333,7 +306,6 @@ module Jekyll opts[:SSLEnable] = true end - private def start_callback(detached) unless detached proc do @@ -348,7 +320,6 @@ module Jekyll end end - private def stop_callback(detached) unless detached proc do @@ -364,13 +335,11 @@ module Jekyll end end - private def mime_types file = File.expand_path("../mime.types", __dir__) WEBrick::HTTPUtils.load_mime_types(file) end - private def read_file(source_dir, file_path) File.read(Jekyll.sanitized_path(source_dir, file_path)) end diff --git a/lib/jekyll/commands/serve/live_reload_reactor.rb b/lib/jekyll/commands/serve/live_reload_reactor.rb index 5f3a4877..eeafa236 100644 --- a/lib/jekyll/commands/serve/live_reload_reactor.rb +++ b/lib/jekyll/commands/serve/live_reload_reactor.rb @@ -81,6 +81,7 @@ module Jekyll end private + def connect(websocket, handshake) @connections_count += 1 if @connections_count == 1 @@ -99,12 +100,10 @@ module Jekyll @websockets << websocket end - private def disconnect(websocket) @websockets.delete(websocket) end - private def print_message(json_message) msg = JSON.parse(json_message) # Not sure what the 'url' command even does in LiveReload. The spec is silent @@ -114,7 +113,6 @@ module Jekyll end end - private def log_error(error) Jekyll.logger.error "LiveReload experienced an error. " \ "Run with --trace for more information." diff --git a/lib/jekyll/commands/serve/servlet.rb b/lib/jekyll/commands/serve/servlet.rb index 567ec313..3b05bf87 100644 --- a/lib/jekyll/commands/serve/servlet.rb +++ b/lib/jekyll/commands/serve/servlet.rb @@ -178,9 +178,8 @@ module Jekyll end # rubocop:enable Naming/MethodName - # - private + def validate_and_ensure_charset(_req, res) key = res.header.keys.grep(%r!content-type!i).first typ = res.header[key] @@ -190,9 +189,6 @@ module Jekyll end end - # - - private def set_defaults hash_ = @jekyll_opts.fetch("webrick", {}).fetch("headers", {}) DEFAULTS.each_with_object(@headers = hash_) do |(key, val), hash| diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index e49eb62b..cf7fea55 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -278,6 +278,7 @@ module Jekyll end private + def style_to_permalink(permalink_style) case permalink_style.to_sym when :pretty @@ -299,14 +300,12 @@ module Jekyll # file - the file from which the config was extracted # # Raises an ArgumentError if given config is not a hash - private def check_config_is_hash!(extracted_config, file) unless extracted_config.is_a?(Hash) raise ArgumentError, "Configuration file: (INVALID) #{file}".yellow end end - private def check_auto(config) if config.key?("auto") || config.key?("watch") Jekyll::Deprecator.deprecation_message "Auto-regeneration can no longer" \ @@ -317,7 +316,6 @@ module Jekyll end end - private def check_server(config) if config.key?("server") Jekyll::Deprecator.deprecation_message "The 'server' configuration option" \ @@ -327,7 +325,6 @@ module Jekyll end end - private def check_pygments(config) if config.key?("pygments") Jekyll::Deprecator.deprecation_message "The 'pygments' configuration option" \ @@ -340,7 +337,6 @@ module Jekyll end end - private def check_include_exclude(config) %w(include exclude).each do |option| if config[option].is_a?(String) @@ -354,7 +350,6 @@ module Jekyll end end - private def check_coderay(config) if (config["kramdown"] || {}).key?("use_coderay") Jekyll::Deprecator.deprecation_message "Please change 'use_coderay'" \ @@ -363,7 +358,6 @@ module Jekyll end end - private def check_maruku(config) if config.fetch("markdown", "kramdown").to_s.casecmp("maruku").zero? Jekyll.logger.abort_with "Error:", "You're using the 'maruku' " \ @@ -380,7 +374,6 @@ module Jekyll # # Raises a Jekyll::Errors::InvalidConfigurationError if the config `plugins` # is a string - private def check_plugins(config) if config.key?("plugins") && config["plugins"].is_a?(String) Jekyll.logger.error "Configuration Error:", "You specified the" \ diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index 3c1c3458..220bc382 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -76,6 +76,7 @@ module Jekyll end private + def custom_processor converter_name = @config["markdown"] if custom_class_allowed?(converter_name) @@ -90,8 +91,6 @@ module Jekyll # # Returns true if the parser name contains only alphanumeric # characters and is defined within Jekyll::Converters::Markdown - - private def custom_class_allowed?(parser_name) parser_name !~ %r![^A-Za-z0-9_]! && self.class.constants.include?( parser_name.to_sym diff --git a/lib/jekyll/converters/markdown/kramdown_parser.rb b/lib/jekyll/converters/markdown/kramdown_parser.rb index b7caab55..cdae8664 100644 --- a/lib/jekyll/converters/markdown/kramdown_parser.rb +++ b/lib/jekyll/converters/markdown/kramdown_parser.rb @@ -47,6 +47,7 @@ module Jekyll end private + def make_accessible(hash = @config) hash.keys.each do |key| hash[key.to_sym] = hash[key] @@ -59,8 +60,6 @@ module Jekyll # config[highlighter] # Where `enable_coderay` is now deprecated because Kramdown # supports Rouge now too. - - private def highlighter return @highlighter if @highlighter @@ -84,7 +83,6 @@ module Jekyll end end - private def strip_coderay_prefix(hash) hash.each_with_object({}) do |(key, val), hsh| cleaned_key = key.to_s.gsub(%r!\Acoderay_!, "") @@ -102,8 +100,6 @@ module Jekyll # If our highlighter is CodeRay we go in to merge the CodeRay defaults # with your "coderay" key if it's there, deprecating it in the # process of you using it. - - private def modernize_coderay_config unless @config["coderay"].empty? Jekyll::Deprecator.deprecation_message( diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 061839f1..a4f989b8 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -416,6 +416,7 @@ module Jekyll end private + def merge_categories!(other) if other.key?("categories") && !other["categories"].nil? if other["categories"].is_a?(String) @@ -425,7 +426,6 @@ module Jekyll end end - private def merge_date!(source) if data.key?("date") data["date"] = Utils.parse_date( @@ -435,7 +435,6 @@ module Jekyll end end - private def merge_defaults defaults = @site.frontmatter_defaults.all( relative_path, @@ -444,7 +443,6 @@ module Jekyll merge_data!(defaults, :source => "front matter defaults") unless defaults.empty? end - private def read_content(opts) self.content = File.read(path, Utils.merged_file_read_opts(site, opts)) if content =~ YAML_FRONT_MATTER_REGEXP @@ -454,7 +452,6 @@ module Jekyll end end - private def read_post_data populate_title populate_categories @@ -462,7 +459,6 @@ module Jekyll generate_excerpt end - private def handle_read_error(error) if error.is_a? Psych::SyntaxError Jekyll.logger.error "Error:", "YAML Exception reading #{path}: #{error.message}" @@ -475,7 +471,6 @@ module Jekyll end end - private def populate_title if relative_path =~ DATE_FILENAME_MATCHER date, slug, ext = Regexp.last_match.captures @@ -491,14 +486,12 @@ module Jekyll data["ext"] ||= ext end - private def modify_date(date) if !data["date"] || data["date"].to_i == site.time.to_i merge_data!({ "date" => date }, :source => "filename") end end - private def generate_excerpt if generate_excerpt? data["excerpt"] ||= Jekyll::Excerpt.new(self) diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index 209a3e0e..1708d5fa 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -316,7 +316,6 @@ module Jekyll .map!(&:last) end - private def item_property(item, property) if item.respond_to?(:to_liquid) property.to_s.split(".").reduce(item.to_liquid) do |subvalue, attribute| @@ -329,7 +328,6 @@ module Jekyll end end - private def as_liquid(item) case item when Hash @@ -353,7 +351,6 @@ module Jekyll end # Parse a string to a Liquid Condition - private def parse_condition(exp) parser = Liquid::Parser.new(exp) left_expr = parser.expression diff --git a/lib/jekyll/filters/date_filters.rb b/lib/jekyll/filters/date_filters.rb index 40028c88..7bdf0fff 100644 --- a/lib/jekyll/filters/date_filters.rb +++ b/lib/jekyll/filters/date_filters.rb @@ -81,7 +81,6 @@ module Jekyll time.strftime("%d #{month_type} %Y") end - private def ordinal(number) return "th" if (11..13).cover?(number) @@ -93,7 +92,6 @@ module Jekyll end end - private def time(input) date = Liquid::Utils.to_date(input) unless date.respond_to?(:to_time) diff --git a/lib/jekyll/filters/grouping_filters.rb b/lib/jekyll/filters/grouping_filters.rb index 4086bbe9..c9cdc654 100644 --- a/lib/jekyll/filters/grouping_filters.rb +++ b/lib/jekyll/filters/grouping_filters.rb @@ -41,16 +41,15 @@ module Jekyll end private + def parse_expression(str) Liquid::Variable.new(str, Liquid::ParseContext.new) end - private def groupable?(element) element.respond_to?(:group_by) end - private def grouped_array(groups) groups.each_with_object([]) do |item, array| array << { diff --git a/lib/jekyll/regenerator.rb b/lib/jekyll/regenerator.rb index 178cb1a9..864bb0c8 100644 --- a/lib/jekyll/regenerator.rb +++ b/lib/jekyll/regenerator.rb @@ -165,7 +165,6 @@ module Jekyll end end - private def regenerate_page?(document) document.asset_file? || document.data["regenerate"] || source_modified_or_dest_missing?( @@ -173,7 +172,6 @@ module Jekyll ) end - private def regenerate_document?(document) !document.write? || document.data["regenerate"] || source_modified_or_dest_missing?( @@ -181,7 +179,6 @@ module Jekyll ) end - private def existing_file_modified?(path) # If one of this file dependencies have been modified, # set the regeneration bit for both the dependency and the file to true diff --git a/lib/jekyll/renderer.rb b/lib/jekyll/renderer.rb index 9c47b256..acd9a4ee 100644 --- a/lib/jekyll/renderer.rb +++ b/lib/jekyll/renderer.rb @@ -166,11 +166,12 @@ module Jekyll output end + private + # Checks if the layout specified in the document actually exists # # layout - the layout to check # Returns nothing - private def validate_layout(layout) if invalid_layout?(layout) Jekyll.logger.warn( @@ -187,7 +188,6 @@ module Jekyll # Render layout content into document.output # # Returns String rendered content - private def render_layout(output, layout, info) payload["content"] = output payload["layout"] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {}) @@ -200,7 +200,6 @@ module Jekyll ) end - private def add_regenerator_dependencies(layout) return unless document.write? site.regenerator.add_dependency( @@ -212,7 +211,6 @@ module Jekyll # Set page content to payload and assign pager if document has one. # # Returns nothing - private def assign_pages! payload["page"] = document.to_liquid payload["paginator"] = if document.respond_to?(:pager) @@ -223,7 +221,6 @@ module Jekyll # Set related posts to payload if document is a post. # # Returns nothing - private def assign_current_document! payload["site"].current_document = document end @@ -231,13 +228,11 @@ module Jekyll # Set highlighter prefix and suffix # # Returns nothing - private def assign_highlighter_options! payload["highlighter_prefix"] = converters.first.highlighter_prefix payload["highlighter_suffix"] = converters.first.highlighter_suffix end - private def assign_layout_data! layout = layouts[document.data["layout"]] if layout @@ -245,7 +240,6 @@ module Jekyll end end - private def permalink_ext document_permalink = document.permalink if document_permalink && !document_permalink.end_with?("/") @@ -254,7 +248,6 @@ module Jekyll end end - private def converter_output_ext if output_exts.size == 1 output_exts.last @@ -263,14 +256,12 @@ module Jekyll end end - private def output_exts @output_exts ||= converters.map do |c| c.output_ext(document.extname) end.compact end - private def liquid_options @liquid_options ||= site.config["liquid"] end diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 25257a64..6264c102 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -403,10 +403,11 @@ module Jekyll @collections_path ||= dir_str.empty? ? source : in_source_dir(dir_str) end + private + # Limits the current posts; removes the posts which exceed the limit_posts # # Returns nothing - private def limit_posts! if limit_posts > 0 limit = posts.docs.length < limit_posts ? posts.docs.length : limit_posts @@ -418,18 +419,15 @@ module Jekyll # already exist. # # Returns The Cleaner - private def site_cleaner @site_cleaner ||= Cleaner.new(self) end - private def configure_plugins self.plugin_manager = Jekyll::PluginManager.new(self) self.plugins = plugin_manager.plugins_path end - private def configure_theme self.theme = nil return if config["theme"].nil? @@ -444,20 +442,17 @@ module Jekyll end end - private def configure_include_paths @includes_load_paths = Array(in_source_dir(config["includes_dir"].to_s)) @includes_load_paths << theme.includes_path if theme && theme.includes_path end - private def configure_file_read_opts self.file_read_opts = {} self.file_read_opts[:encoding] = config["encoding"] if config["encoding"] self.file_read_opts = Jekyll::Utils.merged_file_read_opts(self, {}) end - private def render_docs(payload) collections.each_value do |collection| collection.docs.each do |document| @@ -466,14 +461,12 @@ module Jekyll end end - private def render_pages(payload) pages.flatten.each do |page| render_regenerated(page, payload) end end - private def render_regenerated(document, payload) return unless regenerator.regenerate?(document) document.output = Jekyll::Renderer.new(self, document, payload).run diff --git a/lib/jekyll/utils.rb b/lib/jekyll/utils.rb index e17a4cdc..f52a62ff 100644 --- a/lib/jekyll/utils.rb +++ b/lib/jekyll/utils.rb @@ -313,6 +313,7 @@ module Jekyll end private + def merge_values(target, overwrite) target.merge!(overwrite) do |_key, old_val, new_val| if new_val.nil? @@ -325,14 +326,12 @@ module Jekyll end end - private def merge_default_proc(target, overwrite) if target.is_a?(Hash) && overwrite.is_a?(Hash) && target.default_proc.nil? target.default_proc = overwrite.default_proc end end - private def duplicate_frozen_values(target) target.each do |key, val| target[key] = val.dup if val.frozen? && duplicable?(val) @@ -343,7 +342,6 @@ module Jekyll # # See Utils#slugify for a description of the character sequence specified # by each mode. - private def replace_character_sequence_with_hyphen(string, mode: "default") replaceable_char = case mode diff --git a/lib/jekyll/utils/internet.rb b/lib/jekyll/utils/internet.rb index f895596c..f723469b 100644 --- a/lib/jekyll/utils/internet.rb +++ b/lib/jekyll/utils/internet.rb @@ -23,8 +23,6 @@ module Jekyll !dns("example.com").nil? end - private - module_function def dns(domain) require "resolv" Resolv::DNS.open do |resolver|