Skip to content

Commit

Permalink
Merge pull request #24 from shahinam/travis-build
Browse files Browse the repository at this point in the history
Fix coding standard errors.
  • Loading branch information
shahinam committed Sep 11, 2018
2 parents af30ce8 + a7780c9 commit 9260099
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 1 deletion.
27 changes: 26 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-09-11 23:29:39 +0300 using RuboCop version 0.59.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
Lint/IneffectiveAccessModifier:
Exclude:
Expand All @@ -13,6 +21,14 @@ Lint/RescueException:
Exclude:
- 'lib/sitediff/cli.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: Whitelist.
# Whitelist: present?, blank?, presence, try, try!
Lint/SafeNavigationConsistency:
Exclude:
- 'lib/sitediff/sanitize.rb'

# Offense count: 2
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
Lint/UselessAccessModifier:
Expand All @@ -26,6 +42,7 @@ Metrics/AbcSize:

# Offense count: 6
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 52

Expand Down Expand Up @@ -57,6 +74,14 @@ Naming/ConstantName:
Exclude:
- 'lib/sitediff/sanitize/dom_transform.rb'

# Offense count: 2
# Configuration parameters: .
# SupportedStyles: snake_case, camelCase
Naming/MethodName:
EnforcedStyle: snake_case
Exclude:
- 'lib/sitediff/webserver/resultserver.rb'

# Offense count: 1
Security/MarshalLoad:
Exclude:
Expand Down Expand Up @@ -108,7 +133,7 @@ Style/MultilineTernaryOperator:

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle.
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
Exclude:
Expand Down
2 changes: 2 additions & 0 deletions lib/sitediff/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ def tag?(tag)

def get(tag, path)
return nil unless @read_tags.include? tag

open || (return nil)
val = @dbm[key(tag, path)]
val && Marshal.load(val)
end

def set(tag, path, result)
return unless @write_tags.include? tag

open || return
@dbm[tag.to_s] = 'TRUE'
@dbm[key(tag, path)] = Marshal.dump(result)
Expand Down
1 change: 1 addition & 0 deletions lib/sitediff/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def chdir(files, opts = {})
Dir.chdir(dir) if dir

return unless opts[:search]

begin
SiteDiff::Config.new(files, search: !dir)
rescue SiteDiff::Config::ConfigNotFound
Expand Down
1 change: 1 addition & 0 deletions lib/sitediff/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def self.load_raw_yaml(file)
SiteDiff.log "Reading config file: #{Pathname.new(file).expand_path}"
conf = YAML.load_file(file) || {}
raise InvalidConfig, "Invalid configuration file: '#{file}'" unless conf.is_a? Hash

conf.each_key do |k, _v|
raise InvalidConfig, "Unknown configuration key (#{file}): '#{k}'" unless CONF_KEYS.include? k
end
Expand Down
1 change: 1 addition & 0 deletions lib/sitediff/config/creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def create(opts, &block)
def build_config
%w[before after].each do |tag|
next unless (u = roots[tag.to_sym])

@config[tag] = { 'url' => u }
end

Expand Down
2 changes: 2 additions & 0 deletions lib/sitediff/crawler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def initialize(hydra, base, depth = DEFAULT_DEPTH, &block)
# Handle a newly found relative URI
def add_uri(rel, depth)
return if @found.include? rel

@found << rel

wrapper = UriWrapper.new(@base + rel)
Expand Down Expand Up @@ -63,6 +64,7 @@ def fetched_uri(rel, depth, res)
# Queue them in turn
rels.each do |r|
next if @found.include? r

add_uri(r, depth - 1)
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/sitediff/fetch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def queue_path(path)
# Process fetch results
def process_results(path, results)
return unless results.size == @tags.size

@callback[path, results]
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/sitediff/rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def find_sanitization_candidates
rules_dir = Pathname.new(__FILE__).dirname + 'files' + 'rules'
rules_dir.children.each do |f|
next unless f.file? && f.extname == '.yaml'

conf = YAML.load_file(f)
@candidates.merge(conf['sanitization'])
end
Expand Down Expand Up @@ -55,6 +56,7 @@ def add_config

def add_section(name, rules)
return if rules.empty?

conf = name ? @config[name] : @config
rules.each { |r| r['disabled'] = true } if @disabled
conf['sanitization'] = rules.to_a.sort_by { |r| r['title'] }
Expand Down
1 change: 1 addition & 0 deletions lib/sitediff/sanitize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def canonicalize_rule(name)
want = rules.select { |r| want_rule(r) }
return nil if want.empty?
raise "Too many matching rules of type #{name}" if want.size > 1

want.first
end

Expand Down

0 comments on commit 9260099

Please sign in to comment.