-
-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added rubocop.yml and corrected simple style warnings #283
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ruby: | ||
config_file: .rubocop.yml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,253 @@ | ||
AllCops: | ||
Exclude: | ||
- lib/json-schema/util/uuid.rb | ||
UseCache: false | ||
Style/ClassVars: | ||
Description: Avoid the use of class variables. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-class-vars | ||
Exclude: | ||
- lib/json-schema/validator.rb | ||
Style/CollectionMethods: | ||
Description: Preferred collection methods. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size | ||
Enabled: true | ||
PreferredMethods: | ||
collect: map | ||
collect!: map! | ||
find: detect | ||
find_all: select | ||
reduce: inject | ||
Style/DotPosition: | ||
Description: Checks the position of the dot in multi-line method calls. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains | ||
Enabled: true | ||
EnforcedStyle: trailing | ||
SupportedStyles: | ||
- leading | ||
- trailing | ||
Style/FileName: | ||
Description: Use snake_case for source file names. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files | ||
Enabled: false | ||
Exclude: [] | ||
Style/GuardClause: | ||
Description: Check for conditionals that can be replaced with guard clauses | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals | ||
Enabled: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I vote for enabling this. |
||
MinBodyLength: 1 | ||
Style/IfUnlessModifier: | ||
Description: Favor modifier if/unless usage when you have a single-line body. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier | ||
Enabled: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I also vote for true. |
||
MaxLineLength: 80 | ||
Style/Lambda: | ||
Description: Use the new lambda literal syntax for single-line blocks. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#lambda-multi-line | ||
Enabled: false | ||
Style/OptionHash: | ||
Description: "Don't use option hashes when you can use keyword arguments." | ||
Enabled: false | ||
Style/PredicateName: | ||
Description: Check the names of predicate methods. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark | ||
Enabled: true | ||
NamePrefix: | ||
- is_ | ||
- has_ | ||
- have_ | ||
NamePrefixBlacklist: | ||
- is_ | ||
Exclude: | ||
- spec/**/* | ||
Style/Proc: | ||
Description: Use proc instead of Proc.new. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#proc | ||
Enabled: false | ||
Style/RaiseArgs: | ||
Description: Checks the arguments passed to raise/fail. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages | ||
Enabled: false | ||
EnforcedStyle: exploded | ||
SupportedStyles: | ||
- compact | ||
- exploded | ||
Style/SignalException: | ||
Description: Checks for proper usage of fail and raise. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method | ||
Enabled: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd enable this. I like the differentiation between |
||
EnforcedStyle: semantic | ||
SupportedStyles: | ||
- only_raise | ||
- only_fail | ||
- semantic | ||
Style/SingleLineBlockParams: | ||
Description: Enforces the names of some block params. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks | ||
Enabled: false | ||
Methods: | ||
- reduce: | ||
- a | ||
- e | ||
- inject: | ||
- a | ||
- e | ||
Style/SingleLineMethods: | ||
Description: Avoid single-line methods. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods | ||
Enabled: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Vote true. |
||
AllowIfMethodIsEmpty: true | ||
Style/SpecialGlobalVars: | ||
Description: Avoid Perl-style global variables. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms | ||
Enabled: false | ||
Style/StringLiterals: | ||
Description: Checks if uses of quotes match the configured preference. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals | ||
Enabled: true | ||
EnforcedStyle: double_quotes | ||
SupportedStyles: | ||
- single_quotes | ||
- double_quotes | ||
Style/StringLiteralsInInterpolation: | ||
Description: Checks if uses of quotes inside expressions in interpolated strings | ||
match the configured preference. | ||
Enabled: true | ||
EnforcedStyle: single_quotes | ||
SupportedStyles: | ||
- single_quotes | ||
- double_quotes | ||
Metrics/AbcSize: | ||
Description: A calculated magnitude based on number of assignments, branches, and | ||
conditions. | ||
Enabled: false | ||
Max: 15 | ||
Metrics/BlockNesting: | ||
Description: Avoid excessive block nesting | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count | ||
Enabled: false | ||
Max: 3 | ||
Metrics/ClassLength: | ||
Description: Avoid classes longer than 100 lines of code. | ||
Enabled: false | ||
CountComments: false | ||
Max: 100 | ||
Metrics/LineLength: | ||
Description: Limit lines to 80 characters. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#80-character-limits | ||
Enabled: false | ||
Metrics/ModuleLength: | ||
Description: Avoid modules longer than 100 lines of code. | ||
CountComments: false | ||
Max: 100 | ||
Enabled: false | ||
Metrics/CyclomaticComplexity: | ||
Description: A complexity metric that is strongly correlated to the number of test | ||
cases needed to validate a method. | ||
Enabled: false | ||
Max: 6 | ||
Metrics/MethodLength: | ||
Description: Avoid methods longer than 10 lines of code. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods | ||
Enabled: false | ||
CountComments: false | ||
Max: 10 | ||
Metrics/ParameterLists: | ||
Description: Avoid parameter lists longer than three or four parameters. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params | ||
Enabled: false | ||
Max: 5 | ||
CountKeywordArgs: true | ||
Metrics/PerceivedComplexity: | ||
Description: A complexity metric geared towards measuring complexity for a human | ||
reader. | ||
Enabled: false | ||
Max: 7 | ||
Lint/AssignmentInCondition: | ||
Description: "Don't use assignment in conditions." | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition | ||
Enabled: false | ||
AllowSafeAssignment: true | ||
Style/InlineComment: | ||
Description: Avoid inline comments. | ||
Enabled: false | ||
Style/AccessorMethodName: | ||
Description: Check the naming of accessor methods for get_/set_. | ||
Enabled: false | ||
Style/Alias: | ||
Description: Use alias_method instead of alias. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method | ||
Enabled: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Vote true. |
||
Style/BlockDelimiters: | ||
Description: Avoid using {...} for multi-line blocks (multiline chaining is always ugly). | ||
Prefer {...} over do...end for single-line blocks. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#single-line-blocks | ||
Enabled: true | ||
EnforcedStyle: line_count_based | ||
SupportedStyles: | ||
- line_count_based | ||
- semantic | ||
- braces_for_chaining | ||
Style/Documentation: | ||
Description: Document classes and non-namespace modules. | ||
Enabled: false | ||
Style/EachWithObject: | ||
Description: Prefer `each_with_object` over `inject` or `reduce`. | ||
Enabled: false | ||
Style/HashSyntax: | ||
Description: "Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax { :a => 1, :b => 2 }." | ||
EnforcedStyle: hash_rockets | ||
Enabled: true | ||
SupportedStyles: | ||
- ruby19 | ||
- ruby19_no_mixed_keys | ||
- hash_rockets | ||
Style/ModuleFunction: | ||
Description: Checks for usage of `extend self` in modules. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function | ||
Enabled: false | ||
Style/MultilineBlockChain: | ||
Description: Avoid multi-line chains of blocks. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#single-line-blocks | ||
Enabled: false | ||
Style/OneLineConditional: | ||
Description: Favor the ternary operator(?:) over if/then/else/end constructs. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator | ||
Enabled: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Vote true. |
||
Style/Send: | ||
Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` | ||
may overlap with existing methods. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send | ||
Enabled: false | ||
Style/SpaceInsideHashLiteralBraces: | ||
Description: "Use spaces inside hash literal braces - or don't." | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators | ||
EnforcedStyle: no_space | ||
EnforcedStyleForEmptyBraces: no_space | ||
SupportedStyles: | ||
- space | ||
- no_space | ||
Style/VariableInterpolation: | ||
Description: "Don't interpolate global, instance and class variables directly in strings." | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate | ||
Enabled: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Vote true. |
||
Style/WhenThen: | ||
Description: Use when x then ... for one-line cases. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases | ||
Enabled: false | ||
Style/WordArray: | ||
Description: Use %w or %W for arrays of words. | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-w | ||
Enabled: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Vote true. |
||
Lint/EachWithObjectArgument: | ||
Description: Check for immutable argument given to each_with_object. | ||
Enabled: true | ||
Lint/HandleExceptions: | ||
Description: "Don't suppress exception." | ||
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions | ||
Enabled: false | ||
Lint/LiteralInCondition: | ||
Description: Checks of literals used in conditions. | ||
Enabled: false | ||
Lint/LiteralInInterpolation: | ||
Description: Checks for literals used in interpolation. | ||
Enabled: false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
require 'yaml' | ||
require "yaml" | ||
|
||
version_yaml = YAML.load(File.open('VERSION.yml').read) | ||
version_yaml = YAML.load(File.open("VERSION.yml").read) | ||
version = "#{version_yaml['major']}.#{version_yaml['minor']}.#{version_yaml['patch']}" | ||
gem_name = "json-schema" | ||
|
||
|
@@ -11,17 +11,17 @@ Gem::Specification.new do |s| | |
s.email = "[email protected]" | ||
s.homepage = "http://github.com/ruby-json-schema/json-schema/tree/master" | ||
s.summary = "Ruby JSON Schema Validator" | ||
s.files = Dir[ "lib/**/*", "resources/*.json" ] | ||
s.files = Dir["lib/**/*", "resources/*.json"] | ||
s.require_path = "lib" | ||
s.extra_rdoc_files = ["README.textile","LICENSE.md"] | ||
s.extra_rdoc_files = ["README.textile", "LICENSE.md"] | ||
s.required_ruby_version = ">= 1.8.7" | ||
s.license = "MIT" | ||
s.required_rubygems_version = ">= 1.8" | ||
|
||
s.add_development_dependency "rake" | ||
s.add_development_dependency "minitest", '~> 5.0' | ||
s.add_development_dependency "minitest", "~> 5.0" | ||
s.add_development_dependency "webmock" | ||
s.add_development_dependency "bundler" | ||
|
||
s.add_runtime_dependency "addressable", '~> 2.3.8' | ||
s.add_runtime_dependency "addressable", "~> 2.3.8" | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
require 'rubygems' | ||
require "rubygems" | ||
|
||
if Gem::Specification::find_all_by_name('multi_json').any? | ||
require 'multi_json' | ||
if Gem::Specification.find_all_by_name("multi_json").any? | ||
require "multi_json" | ||
|
||
# Force MultiJson to load an engine before we define the JSON constant here; otherwise, | ||
# it looks for things that are under the JSON namespace that aren't there (since we have defined it here) | ||
MultiJson.respond_to?(:adapter) ? MultiJson.adapter : MultiJson.engine | ||
end | ||
|
||
require 'json-schema/util/array_set' | ||
require 'json-schema/util/uri' | ||
require 'json-schema/schema' | ||
require 'json-schema/schema/reader' | ||
require 'json-schema/validator' | ||
require "json-schema/util/array_set" | ||
require "json-schema/util/uri" | ||
require "json-schema/schema" | ||
require "json-schema/schema/reader" | ||
require "json-schema/validator" | ||
|
||
Dir[File.join(File.dirname(__FILE__), "json-schema/attributes/*.rb")].each {|file| require file } | ||
Dir[File.join(File.dirname(__FILE__), "json-schema/attributes/formats/*.rb")].each {|file| require file } | ||
Dir[File.join(File.dirname(__FILE__), "json-schema/validators/*.rb")].sort!.each {|file| require file } | ||
Dir[File.join(File.dirname(__FILE__), "json-schema/attributes/*.rb")].each { |file| require file } | ||
Dir[File.join(File.dirname(__FILE__), "json-schema/attributes/formats/*.rb")].each { |file| require file } | ||
Dir[File.join(File.dirname(__FILE__), "json-schema/validators/*.rb")].sort!.each { |file| require file } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer reduce over inject here.