From 619837da6224f1e2d9945225305ee5c6251dfdd9 Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Wed, 1 Mar 2017 09:34:43 +0100 Subject: [PATCH] Lint --- .rubocop.yml | 32 ++++++++++++++++++++++++++++++++ .rubocop_todo.yml | 15 +++++++++++++++ lib/rebel/sql.rb | 10 +++++----- 3 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..89086a0 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,32 @@ +inherit_from: .rubocop_todo.yml + +Metrics/LineLength: + Enabled: false + +Metrics/ParameterLists: + Enabled: false + +Style/Documentation: + Enabled: false + +Style/ClassAndModuleChildren: + Enabled: false + +Metrics/ModuleLength: + Enabled: false + +Style/TrailingCommaInLiteral: + EnforcedStyleForMultiline: comma + +Style/TrailingCommaInArguments: + EnforcedStyleForMultiline: comma + +Style/NestedParenthesizedCalls: + Enabled: false + +Style/BracesAroundHashParameters: + Exclude: + - 'test/test_*.rb' + +Style/IndentArray: + EnforcedStyle: consistent diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..b54c8f9 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,15 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2017-02-28 19:06:39 +0100 using RuboCop version 0.47.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 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: prefer_alias, prefer_alias_method +Style/Alias: + Exclude: + - 'test/helper.rb' diff --git a/lib/rebel/sql.rb b/lib/rebel/sql.rb index 3adb991..e495073 100644 --- a/lib/rebel/sql.rb +++ b/lib/rebel/sql.rb @@ -105,7 +105,7 @@ module Rebel::SQL end def update(table_name, set: nil, where: nil, inner: nil, left: nil, right: nil) - fail ArgumentError if set.nil? + raise ArgumentError if set.nil? <<-SQL UPDATE #{Rebel::SQL.name(table_name)} @@ -180,9 +180,9 @@ module Rebel::SQL case v when Raw then v when String then raw "'#{v.tr("'", "''")}'" - when Fixnum, Bignum, Integer then raw v.to_s + when Integer then raw v.to_s when nil then raw 'NULL' - else fail NotImplementedError, v.inspect + else raise NotImplementedError, v.inspect end end @@ -218,7 +218,7 @@ module Rebel::SQL case e when Array then clause_term(e[0], e[1]) when Raw, String then e - else fail NotImplementedError, e.class + else raise NotImplementedError, e.class end end.join(' AND ') end @@ -226,7 +226,7 @@ module Rebel::SQL def where?(clause) return "WHERE #{clause}" if clause.is_a?(Raw) || clause.is_a?(String) - (clause && clause.any?) ? "WHERE #{Rebel::SQL.and_clause(clause)}" : nil + clause && clause.any? ? "WHERE #{Rebel::SQL.and_clause(clause)}" : nil end def inner?(join)