Skip to content

Commit

Permalink
Fix code style with help of Rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
alsemyonov committed Jul 5, 2016
1 parent 17923f6 commit a2d97d6
Show file tree
Hide file tree
Showing 79 changed files with 475 additions and 264 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require: rubocop-rspec
inherit_from: .rubocop_todo.yml
91 changes: 91 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-07-05 04:35:13 +0300 using RuboCop version 0.41.1.
# 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: 1
Lint/ShadowingOuterLocalVariable:
Exclude:
- 'examples/atom.rb'

# Offense count: 9
Metrics/AbcSize:
Max: 70

# Offense count: 2
Metrics/CyclomaticComplexity:
Max: 14

# Offense count: 125
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
# URISchemes: http, https
Metrics/LineLength:
Max: 265

# Offense count: 10
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 46

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 203

# Offense count: 3
Metrics/PerceivedComplexity:
Max: 15

# Offense count: 61
Style/AsciiComments:
Enabled: false

# Offense count: 2
Style/CaseEquality:
Exclude:
- 'lib/xommelier/xml/element/serialization.rb'

# Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'lib/xommelier/core_ext/uri.rb'

# Offense count: 110
Style/Documentation:
Enabled: false

# Offense count: 1
Style/DoubleNegation:
Exclude:
- 'lib/xommelier/xml/element.rb'

# Offense count: 1
Style/EachWithObject:
Exclude:
- 'lib/xommelier/xml/element/serialization.rb'

# Offense count: 1
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'lib/xommelier/xml/element/namespace.rb'

# Offense count: 1
Style/IfInsideElse:
Exclude:
- 'lib/xommelier/xml/element/serialization.rb'

# Offense count: 1
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
# NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_
# NameWhitelist: is_a?
Style/PredicateName:
Exclude:
- 'spec/**/*'
- 'lib/xommelier/ds.rb'
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
source 'https://rubygems.org'

# Specify your gem's dependencies in xommelier.gemspec
gemspec


gem 'simplecov', require: false, group: :test
4 changes: 1 addition & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ RSpec::Core::RakeTask.new(:spec)
task default: :spec

require 'rubocop/rake_task'
RuboCop::RakeTask.new do |task|
task.requires << 'rubocop-rspec'
end
RuboCop::RakeTask.new
task default: :rubocop

require 'yard'
Expand Down
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/setup'
require 'xommelier'
require 'pry'
Expand Down
12 changes: 6 additions & 6 deletions bin/rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
# this file is here to facilitate running it.
#

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath)

require "rubygems"
require "bundler/setup"
require 'rubygems'
require 'bundler/setup'

load Gem.bin_path("rake", "rake")
load Gem.bin_path('rake', 'rake')
12 changes: 6 additions & 6 deletions bin/rubocop
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
# this file is here to facilitate running it.
#

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath)

require "rubygems"
require "bundler/setup"
require 'rubygems'
require 'bundler/setup'

load Gem.bin_path("rubocop", "rubocop")
load Gem.bin_path('rubocop', 'rubocop')
1 change: 1 addition & 0 deletions examples/atom.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'xommelier/atom'
require 'xommelier/atom/threading'
require 'active_support/core_ext'
Expand Down
1 change: 1 addition & 0 deletions examples/xml.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'xommelier'

class Author < Xommelier::Xml::Element
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/atom.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/atom/category.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/atom/content.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/atom/entry.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/atom/feed.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/atom/full.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/atom/generator.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/atom/history.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
3 changes: 2 additions & 1 deletion lib/xommelier/atom/link.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand All @@ -13,7 +14,7 @@ class Link < Xml::Element
attribute :href, type: Uri

may do
attribute :rel#, type: Enum(:alternate, :related, :self, :enclosure, :via)
attribute :rel # , type: Enum(:alternate, :related, :self, :enclosure, :via)
attribute :type
attribute :hreflang
attribute :title
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/atom/links_extension.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/atom/person.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/atom/source.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/atom/threading.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
7 changes: 6 additions & 1 deletion lib/xommelier/common.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand All @@ -15,7 +16,11 @@ def self.from_xommelier(value)
return unless value
case value
when String
value = rfc2822(value) rescue parse(value)
value = begin
rfc2822(value)
rescue
parse(value)
end
at(value)
when Time, Date, DateTime
at(value.to_time)
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/core_ext.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
5 changes: 3 additions & 2 deletions lib/xommelier/core_ext/boolean.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand All @@ -9,11 +10,11 @@
require 'xommelier'

class Boolean
#noinspection RubyStringKeysInHashInspection,RubyDuplicatedKeysInHashInspection
# noinspection RubyStringKeysInHashInspection,RubyDuplicatedKeysInHashInspection
BOOLEAN_MAP = {
true => true, 'true' => true, 'TRUE' => true, '1' => true, '1.0' => true, 1 => true, 1.0 => true,
false => false, 'false' => false, 'FALSE' => false, '0' => false, '0.0' => false, 0 => false, 0.0 => false, nil => false, '' => false
}
}.freeze

def self.from_xommelier(value)
BOOLEAN_MAP[value]
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/core_ext/date.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/core_ext/float.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/core_ext/numeric.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/core_ext/string.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
1 change: 1 addition & 0 deletions lib/xommelier/core_ext/symbol.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand Down
3 changes: 2 additions & 1 deletion lib/xommelier/core_ext/time.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand All @@ -9,7 +10,7 @@

class Time
def self.from_xommelier(value)
return if value == nil
return if value.nil?
case value
when String
Time.xmlschema(value)
Expand Down
3 changes: 2 additions & 1 deletion lib/xommelier/core_ext/uri.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

################################################
# © Alexander Semyonov, 2011—2013, MIT License #
Expand All @@ -17,7 +18,7 @@ def to_xommelier

class Uri < String
def self.from_xommelier(value)
return if value == nil
return if value.nil?
case value
when URI::Generic
value
Expand Down
Loading

0 comments on commit a2d97d6

Please sign in to comment.