From 45a8ec13bc1c2503b518486aaec087d9a0befd85 Mon Sep 17 00:00:00 2001 From: Enrique Gonzalez Date: Tue, 15 Mar 2016 08:08:26 -0400 Subject: [PATCH] Updated rubocop config file and fixed some violations. --- .rubocop.yml | 637 +-------------------------------- lib/bamboozled/api/time_off.rb | 7 +- lib/bamboozled/errors.rb | 26 +- lib/bamboozled/version.rb | 2 +- 4 files changed, 26 insertions(+), 646 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 61ff7d1..940bc20 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,660 +1,37 @@ -require: rubocop-rspec +# require: rubocop-rspec -AllCops: - RunRailsCops: false - DisplayCopNames: false - DisplayStyleGuide: false - StyleGuideCopsOnly: false - DisabledByDefault: true - -Style/AccessModifierIndentation: - Enabled: true - -Style/AccessorMethodName: - Enabled: true - -Style/Alias: - Enabled: true - -Style/AlignArray: - Enabled: true +Rails: + Enabled: false Style/AlignHash: Enabled: true EnforcedHashRocketStyle: table EnforcedColonStyle: table -Style/AlignParameters: - Enabled: true - -Style/AndOr: - Enabled: true - -Style/ArrayJoin: - Enabled: true - -Style/AsciiComments: - Enabled: true - -Style/AsciiIdentifiers: - Enabled: true - -Style/Attr: - Enabled: true - -Style/BeginBlock: - Enabled: true - -Style/BarePercentLiterals: - Enabled: true - -Style/BlockComments: - Enabled: true - -Style/BlockEndNewline: - Enabled: true - -Style/BlockDelimiters: - Enabled: true - -Style/BracesAroundHashParameters: - Enabled: true - -Style/CaseEquality: - Enabled: true - -Style/CaseIndentation: - Enabled: true - -Style/CharacterLiteral: - Enabled: true - -Style/ClassAndModuleCamelCase: - Enabled: true - -Style/ClassAndModuleChildren: - Enabled: true - -Style/ClassCheck: - Enabled: true - -Style/ClassMethods: - Enabled: true - -Style/ClassVars: - Enabled: true - -Style/ClosingParenthesisIndentation: - Enabled: true - -Style/ColonMethodCall: - Enabled: true - -Style/CommandLiteral: +Style/CollectionMethods: Enabled: true Style/CommentAnnotation: Enabled: false -Style/CommentIndentation: - Enabled: true - -Style/ConstantName: - Enabled: true - -Style/DefWithParentheses: - Enabled: true - -Style/DeprecatedHashMethods: - Enabled: true - Style/Documentation: Enabled: false -Style/DotPosition: - Enabled: true - -Style/DoubleNegation: - Enabled: true - -Style/EachWithObject: - Enabled: true - -Style/ElseAlignment: - Enabled: true - -Style/EmptyElse: - Enabled: true - -Style/EmptyLineBetweenDefs: - Enabled: true - -Style/EmptyLines: - Enabled: true - -Style/EmptyLinesAroundAccessModifier: - Enabled: true - -Style/EmptyLinesAroundBlockBody: - Enabled: true - -Style/EmptyLinesAroundClassBody: - Enabled: true - -Style/EmptyLinesAroundModuleBody: - Enabled: true - -Style/EmptyLinesAroundMethodBody: - Enabled: true - -Style/EmptyLiteral: - Enabled: true - -Style/EndBlock: - Enabled: true - -Style/EndOfLine: - Enabled: true - -Style/EvenOdd: - Enabled: true - -Style/ExtraSpacing: - Enabled: true - -Style/FileName: - Enabled: true - -Style/InitialIndentation: - Enabled: true - -Style/FirstParameterIndentation: - Enabled: true - -Style/FlipFlop: - Enabled: true - -Style/For: - Enabled: true - -Style/FormatString: - Enabled: true - -Style/GlobalVars: - Enabled: true - -Style/GuardClause: - Enabled: true - -Style/HashSyntax: - Enabled: true - -Style/IfUnlessModifier: - Enabled: true - -Style/IfWithSemicolon: - Enabled: true - -Style/IndentationConsistency: - Enabled: true - -Style/IndentationWidth: - Enabled: true - -Style/IndentArray: - Enabled: true - -Style/IndentHash: - Enabled: true - -Style/InfiniteLoop: - Enabled: true - -Style/Lambda: - Enabled: true - -Style/LambdaCall: - Enabled: true - -Style/LeadingCommentSpace: - Enabled: true - -Style/LineEndConcatenation: - Enabled: true - -Style/MethodCallParentheses: - Enabled: true - Style/MethodCalledOnDoEndBlock: Enabled: true -Style/MethodDefParentheses: - Enabled: true - -Style/MethodName: - Enabled: true - -Style/ModuleFunction: - Enabled: true - -Style/MultilineBlockChain: - Enabled: true - -Style/MultilineBlockLayout: - Enabled: true - -Style/MultilineIfThen: - Enabled: true - -Style/MultilineOperationIndentation: - Enabled: true - -Style/MultilineTernaryOperator: - Enabled: true - -Style/NegatedIf: - Enabled: true - -Style/NegatedWhile: - Enabled: true - -Style/NestedTernaryOperator: - Enabled: true - -Style/Next: - Enabled: true - -Style/NilComparison: - Enabled: true - -Style/NonNilCheck: - Enabled: true - -Style/Not: - Enabled: true - -Style/NumericLiterals: - Enabled: true - -Style/OneLineConditional: - Enabled: true - -Style/OpMethod: - Enabled: true - Style/OptionHash: Enabled: true -Style/OptionalArguments: - Enabled: true - -Style/ParallelAssignment: - Enabled: true - -Style/ParenthesesAroundCondition: - Enabled: true - -Style/PercentLiteralDelimiters: - Enabled: true - -Style/PercentQLiterals: - Enabled: true - -Style/PerlBackrefs: - Enabled: true - -Style/PredicateName: - Enabled: true - -Style/Proc: - Enabled: true - -Style/RaiseArgs: - Enabled: true - -Style/RedundantBegin: - Enabled: true - -Style/RedundantException: - Enabled: true - -Style/RedundantReturn: - Enabled: true - -Style/RedundantSelf: - Enabled: true - -Style/RegexpLiteral: - Enabled: true - -Style/RescueEnsureAlignment: - Enabled: true - -Style/RescueModifier: - Enabled: true - -Style/SelfAssignment: - Enabled: true - -Style/Semicolon: - Enabled: true - -Style/SignalException: - Enabled: true - Style/SingleLineBlockParams: Enabled: false -Style/SingleLineMethods: - Enabled: true - -Style/SingleSpaceBeforeFirstArg: - Enabled: true - -Style/SpaceAfterColon: - Enabled: true - -Style/SpaceAfterComma: - Enabled: true - -Style/SpaceAfterControlKeyword: - Enabled: true - -Style/SpaceAfterMethodName: - Enabled: true - -Style/SpaceAfterNot: - Enabled: true - -Style/SpaceAfterSemicolon: - Enabled: true - -Style/SpaceBeforeBlockBraces: - Enabled: true - -Style/SpaceBeforeComma: - Enabled: true - -Style/SpaceBeforeComment: - Enabled: true - -Style/SpaceBeforeSemicolon: - Enabled: true - -Style/SpaceInsideBlockBraces: - Enabled: true - -Style/SpaceAroundBlockParameters: - Enabled: true - -Style/SpaceAroundEqualsInParameterDefault: - Enabled: true - -Style/SpaceAroundOperators: - Enabled: true - -Style/SpaceBeforeModifierKeyword: - Enabled: true - -Style/SpaceInsideBrackets: - Enabled: true - -Style/SpaceInsideHashLiteralBraces: - Enabled: true - -Style/SpaceInsideParens: - Enabled: true - -Style/SpaceInsideRangeLiteral: - Enabled: true - -Style/SpaceInsideStringInterpolation: - Enabled: true - -Style/SpecialGlobalVars: - Enabled: true - Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes -Style/StringLiteralsInInterpolation: - Enabled: true - -Style/StructInheritance: +Style/SymbolArray: Enabled: true -Style/SymbolLiteral: - Enabled: true - -Style/SymbolProc: - Enabled: true - -Style/Tab: - Enabled: true - -Style/TrailingBlankLines: - Enabled: true - -Style/TrailingComma: - Enabled: true - -Style/TrailingWhitespace: - Enabled: true - -Style/TrivialAccessors: - Enabled: true - -Style/UnlessElse: - Enabled: true - -Style/UnneededCapitalW: - Enabled: true - -Style/UnneededPercentQ: - Enabled: true - -Style/TrailingUnderscoreVariable: - Enabled: true - -Style/VariableInterpolation: - Enabled: true - -Style/VariableName: - Enabled: true - -Style/WhenThen: - Enabled: true - -Style/WhileUntilDo: - Enabled: true - -Style/WhileUntilModifier: - Enabled: true - -Style/WordArray: - Enabled: true - -#################### Metrics ################################ - -Metrics/AbcSize: - Enabled: true - -Metrics/BlockNesting: - Enabled: true - -Metrics/ClassLength: - Enabled: true - -Metrics/ModuleLength: - Enabled: true - -Metrics/CyclomaticComplexity: - Enabled: true - -Metrics/LineLength: - Enabled: true - -Metrics/MethodLength: - Enabled: true - -Metrics/ParameterLists: - Enabled: true - -Metrics/PerceivedComplexity: - Enabled: true - -#################### Lint ################################ - -Lint/AmbiguousOperator: - Enabled: true - -Lint/AmbiguousRegexpLiteral: - Enabled: true - -Lint/AssignmentInCondition: - Enabled: true - -Lint/BlockAlignment: - Enabled: true - -Lint/CircularArgumentReference: - Enabled: true - -Lint/ConditionPosition: - Enabled: true - -Lint/Debugger: - Enabled: true - -Lint/DefEndAlignment: - Enabled: true - -Lint/DeprecatedClassMethods: - Enabled: true - -Lint/DuplicateMethods: - Enabled: true - -Lint/EachWithObjectArgument: - Enabled: true - -Lint/ElseLayout: - Enabled: true - -Lint/EmptyEnsure: - Enabled: true - -Lint/EmptyInterpolation: - Enabled: true - -Lint/EndAlignment: - Enabled: true - -Lint/EndInMethod: - Enabled: true - -Lint/EnsureReturn: - Enabled: true - -Lint/Eval: - Enabled: true - -Lint/FormatParameterMismatch: - Enabled: true - -Lint/HandleExceptions: - Enabled: true - -Lint/InvalidCharacterLiteral: - Enabled: true - -Lint/LiteralInCondition: - Enabled: true - -Lint/LiteralInInterpolation: - Enabled: true - -Lint/Loop: - Enabled: true - -Lint/NestedMethodDefinition: - Enabled: true - -Lint/NonLocalExitFromIterator: - Enabled: true - -Lint/ParenthesesAsGroupedExpression: - Enabled: true - -Lint/RequireParentheses: - Enabled: true - -Lint/RescueException: - Enabled: true - -Lint/ShadowingOuterLocalVariable: - Enabled: true - -Lint/SpaceBeforeFirstArg: - Enabled: true - -Lint/StringConversionInInterpolation: - Enabled: true - -Lint/UnderscorePrefixedVariableName: - Enabled: true - -Lint/UnneededDisable: - Enabled: true - -Lint/UnusedBlockArgument: - Enabled: true - -Lint/UnusedMethodArgument: - Enabled: true - -Lint/UnreachableCode: - Enabled: true - -Lint/UselessAccessModifier: - Enabled: true - -Lint/UselessAssignment: - Enabled: true - -Lint/UselessComparison: - Enabled: true - -Lint/UselessElseWithoutRescue: - Enabled: true - -Lint/UselessSetterCall: - Enabled: true - -Lint/Void: - Enabled: true - -##################### Performance ############################# - -Performance/Count: - Enabled: true - -Performance/Detect: - Enabled: true - -Performance/FlatMap: - Enabled: true - EnabledForFlattenWithoutParams: false - -Performance/ReverseEach: - Enabled: true - -Performance/Sample: - Enabled: true - -Performance/Size: - Enabled: true - -Performance/StringReplacement: - Enabled: true +RSpec/FilePath: + Enabled: false diff --git a/lib/bamboozled/api/time_off.rb b/lib/bamboozled/api/time_off.rb index 7d7b816..f9df7fd 100644 --- a/lib/bamboozled/api/time_off.rb +++ b/lib/bamboozled/api/time_off.rb @@ -1,9 +1,8 @@ module Bamboozled module API class TimeOff < Base - def requests(options = {}) - allowed_parameters = [:id, :action, :employeeId, :start, :end, :type, :status] + allowed_parameters = %i(id action employeeId start end type status) options = options.keep_if { |k,_| allowed_parameters.include? k } # Convert non string dates to strings. @@ -14,7 +13,9 @@ def requests(options = {}) # Make sure all statuses are allowed if options[:status] allowed_statuses = %w(approved denied superceded requested canceled) - options[:status] = Array(options[:status]).keep_if { |v| allowed_statuses.include? v }.join(",") + options[:status] = Array(options[:status]) + .keep_if { |v| allowed_statuses.include? v } + .join(",") end request(:get, "time_off/requests?#{URI.encode_www_form(options)}") diff --git a/lib/bamboozled/errors.rb b/lib/bamboozled/errors.rb index e818bbb..5f18d4f 100644 --- a/lib/bamboozled/errors.rb +++ b/lib/bamboozled/errors.rb @@ -12,20 +12,22 @@ def initialize(response, params = {}, hint = nil) end def to_s - "#{self.class.to_s} : #{response.code} #{response.body}" + (hint ? "\n#{hint}" : "") + "#{self.class} : #{response.code} #{response.body}".tap do |msg| + msg << "\n#{hint}" if hint + end end end - class BadRequest < HTTPError; end #400 - class Unauthorized < HTTPError ; end # - class AuthenticationFailed < HTTPError ; end # - class Forbidden < HTTPError ; end # 403 - class NotFound < HTTPError; end # 404 - class NotAcceptable < HTTPError; end # 406 - class Conflict < HTTPError; end # 409 - class LimitExceeded < HTTPError; end # 429 - class InternalServerError < HTTPError; end # 500 - class GatewayError < HTTPError; end # 502 - class ServiceUnavailable < HTTPError; end # 503 + class BadRequest < HTTPError; end + class Unauthorized < HTTPError; end + class AuthenticationFailed < HTTPError; end + class Forbidden < HTTPError; end + class NotFound < HTTPError; end + class NotAcceptable < HTTPError; end + class Conflict < HTTPError; end + class LimitExceeded < HTTPError; end + class InternalServerError < HTTPError; end + class GatewayError < HTTPError; end + class ServiceUnavailable < HTTPError; end class InformBamboo < HTTPError; end end diff --git a/lib/bamboozled/version.rb b/lib/bamboozled/version.rb index 5f89707..802548d 100644 --- a/lib/bamboozled/version.rb +++ b/lib/bamboozled/version.rb @@ -1,3 +1,3 @@ module Bamboozled - VERSION = "0.0.7" + VERSION = "0.0.7".freeze end