[Groonga-commit] droonga/fluent-plugin-droonga at d6925d7 [master] Use "and" instead of "&&" for all logical AND operations

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Feb 14 12:43:44 JST 2014


Kouhei Sutou	2014-02-14 12:43:44 +0900 (Fri, 14 Feb 2014)

  New Revision: d6925d75c5783d0b6b2f08859ef9537a99e3a7a7
  https://github.com/droonga/fluent-plugin-droonga/commit/d6925d75c5783d0b6b2f08859ef9537a99e3a7a7

  Message:
    Use "and" instead of "&&" for all logical AND operations

  Modified files:
    lib/droonga/distributed_command_planner.rb
    lib/droonga/forwarder.rb
    lib/droonga/handler_runner.rb
    lib/droonga/plugin/collector/basic.rb
    lib/droonga/plugin/collector/search.rb
    lib/droonga/plugin/planner/distributed_search_planner.rb
    lib/droonga/plugins/error.rb
    lib/droonga/plugins/watch.rb

  Modified: lib/droonga/distributed_command_planner.rb (+1 -1)
===================================================================
--- lib/droonga/distributed_command_planner.rb    2014-02-14 12:39:28 +0900 (a7b8dd5)
+++ lib/droonga/distributed_command_planner.rb    2014-02-14 12:43:44 +0900 (6928afd)
@@ -45,7 +45,7 @@ module Droonga
       return unless params
       params.each do |name, reducer|
         gatherer = nil
-        if reducer.is_a?(Hash) && reducer[:gather]
+        if reducer.is_a?(Hash) and reducer[:gather]
           gatherer = reducer[:gather]
           reducer = reducer[:reduce]
         end

  Modified: lib/droonga/forwarder.rb (+2 -1)
===================================================================
--- lib/droonga/forwarder.rb    2014-02-14 12:39:28 +0900 (e994c6e)
+++ lib/droonga/forwarder.rb    2014-02-14 12:43:44 +0900 (7540a96)
@@ -50,7 +50,8 @@ module Droonga
     private
     def output(receiver, message, command, arguments)
       $log.trace("#{log_tag}: output: start")
-      unless receiver.is_a?(String) && command.is_a?(String)
+      # TODO: IMPROVE ME: Should not use "unless" and "and". It is confused.
+      unless receiver.is_a?(String) and command.is_a?(String)
         $log.trace("#{log_tag}: output: abort: invalid argument",
                    :receiver => receiver,
                    :command  => command)

  Modified: lib/droonga/handler_runner.rb (+1 -1)
===================================================================
--- lib/droonga/handler_runner.rb    2014-02-14 12:39:28 +0900 (8030ced)
+++ lib/droonga/handler_runner.rb    2014-02-14 12:43:44 +0900 (c795d19)
@@ -70,7 +70,7 @@ module Droonga
 
     private
     def prepare
-      if @database_name && !@database_name.empty?
+      if @database_name and !@database_name.empty?
         @context = Groonga::Context.new
         @database =****@conte*****_database(@database_name)
       end

  Modified: lib/droonga/plugin/collector/basic.rb (+3 -3)
===================================================================
--- lib/droonga/plugin/collector/basic.rb    2014-02-14 12:39:28 +0900 (285f19d)
+++ lib/droonga/plugin/collector/basic.rb    2014-02-14 12:43:44 +0900 (eba1fbc)
@@ -51,7 +51,7 @@ module Droonga
 
       case deal["type"]
       when "and"
-        reduced_value = left_value && right_value
+        reduced_value = left_value and right_value
       when "or"
         reduced_value = left_value || right_value
       when "sum"
@@ -73,7 +73,7 @@ module Droonga
     end
 
     def apply_output_range(items, output)
-      if items && items.is_a?(Array)
+      if items and items.is_a?(Array)
         offset = output["offset"] || 0
         unless offset.zero?
           items = items[offset..-1] || []
@@ -90,7 +90,7 @@ module Droonga
     def sum(x, y)
       return x || y if x.nil? or y.nil?
 
-      if x.is_a?(Hash) && y.is_a?(Hash)
+      if x.is_a?(Hash) and y.is_a?(Hash)
         x.merge(y)
       else
         x + y

  Modified: lib/droonga/plugin/collector/search.rb (+2 -2)
===================================================================
--- lib/droonga/plugin/collector/search.rb    2014-02-14 12:39:28 +0900 (7f4d2ee)
+++ lib/droonga/plugin/collector/search.rb    2014-02-14 12:43:44 +0900 (8adfb74)
@@ -26,7 +26,7 @@ module Droonga
       output = body ? body[input_name] : input_name
       if output.is_a?(Hash)
         elements = output["elements"]
-        if elements && elements.is_a?(Hash)
+        if elements and elements.is_a?(Hash)
           # because "count" mapper requires all records,
           # I have to apply it at first, before "limit" and "offset" are applied.
           count_mapper = elements["count"]
@@ -39,7 +39,7 @@ module Droonga
           end
 
           records_mapper = elements["records"]
-          if records_mapper && result["records"]
+          if records_mapper and result["records"]
             if records_mapper["no_output"]
               result.delete("records")
             else

  Modified: lib/droonga/plugin/planner/distributed_search_planner.rb (+9 -9)
===================================================================
--- lib/droonga/plugin/planner/distributed_search_planner.rb    2014-02-14 12:39:28 +0900 (0db8ffe)
+++ lib/droonga/plugin/planner/distributed_search_planner.rb    2014-02-14 12:43:44 +0900 (3800a51)
@@ -60,7 +60,7 @@ module Droonga
 
     def ensure_unifiable!
       @queries.each do |name, query|
-        if unifiable?(name) && query["output"]
+        if unifiable?(name) and query["output"]
           query["output"]["unifiable"] = true
         end
       end
@@ -80,7 +80,7 @@ module Droonga
       # Skip reducing phase for a result with no output.
       if output.nil? or
            output["elements"].nil? or
-           (!output["elements"].include?("count") &&
+           (!output["elements"].include?("count") and
             !output["elements"].include?("records"))
         return
       end
@@ -111,7 +111,7 @@ module Droonga
         # So we have to override the format and restore it on the gathering
         # phase.
         @records_format = @output["format"] || "simple"
-        if @output["format"] && @output["format"] != "simple"
+        if @output["format"] and @output["format"] != "simple"
           @output["format"] = "simple"
         end
 
@@ -157,10 +157,10 @@ module Droonga
           updated_output_limit = final_offset + final_limit
         end
 
-        if updated_sort_limit && updated_sort_limit != @query["sortBy"]["limit"]
+        if updated_sort_limit and updated_sort_limit != @query["sortBy"]["limit"]
           @query["sortBy"]["limit"] = updated_sort_limit
         end
-        if updated_output_limit && @output["limit"] && updated_output_limit != @output["limit"]
+        if updated_output_limit and @output["limit"] and updated_output_limit != @output["limit"]
           @output["limit"] = updated_output_limit
         end
       end
@@ -198,7 +198,7 @@ module Droonga
       end
 
       def calculate_output_offset!
-        @output["offset"] = 0 if have_records? && @output["offset"]
+        @output["offset"] = 0 if have_records? and @output["offset"]
       end
 
       def final_offset
@@ -206,7 +206,7 @@ module Droonga
       end
 
       def final_limit
-        if @original_sort_limit == UNLIMITED && @original_output_limit == UNLIMITED
+        if @original_sort_limit == UNLIMITED and @original_output_limit == UNLIMITED
           UNLIMITED
         else
           if @original_sort_limit == UNLIMITED
@@ -295,7 +295,7 @@ module Droonga
       def update_output_attributes!
         @output["attributes"] = array_style_attributes
         @output["attributes"] += sort_attribute_names
-        if unifiable? && !source_column_names.include?("_key")
+        if unifiable? and !source_column_names.include?("_key")
           @output["attributes"] << "_key"
         end
       end
@@ -376,7 +376,7 @@ module Droonga
           "type"      => "sort",
           "operators" => operators,
         }
-        if unifiable? && !key_column_index.nil?
+        if unifiable? and !key_column_index.nil?
           reducer["key_column"] = key_column_index
         end
 

  Modified: lib/droonga/plugins/error.rb (+1 -1)
===================================================================
--- lib/droonga/plugins/error.rb    2014-02-14 12:39:28 +0900 (f19815b)
+++ lib/droonga/plugins/error.rb    2014-02-14 12:43:44 +0900 (b58274d)
@@ -25,7 +25,7 @@ module Droonga
 
         def adapt_output(output_message)
           errors = output_message.body["errors"]
-          if errors && !errors.empty?
+          if errors and !errors.empty?
             output_message.errors = errors
 
             status_codes = []

  Modified: lib/droonga/plugins/watch.rb (+5 -1)
===================================================================
--- lib/droonga/plugins/watch.rb    2014-02-14 12:39:28 +0900 (4e8187f)
+++ lib/droonga/plugins/watch.rb    2014-02-14 12:43:44 +0900 (4b1482b)
@@ -51,7 +51,11 @@ module Droonga
           subscriber = request["subscriber"]
           condition = request["condition"]
           route = request["route"] || message["from"]
-          query = condition && condition.to_json
+          if condition
+            query = condition.to_json
+          else
+            query = nilondition
+          end
           [subscriber, condition, query, route]
         end
       end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index