前提
開発環境は、以下のようになります。
Rubu:3.1.2
Rails:6.0.4.1
rubocopでのLintチェックのエラーが解消できない件
実現したいこと
下記のコードのLintチェックが通りません。
if (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time < rest_fish_time && ((count - let_foodstuff_capacity) % let_foodstuff_capacity).zero? ((let_foodstuff_capacity - cookware_capacity) / cookware_capacity).ceil * cooking_time + cooking_total_time + (rest_fish_time - (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time + (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time) * ((count - let_foodstuff_capacity) / let_foodstuff_capacity) elsif (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time < rest_fish_time && (count - let_foodstuff_capacity) % let_foodstuff_capacity != 0 ((let_foodstuff_capacity - cookware_capacity) / cookware_capacity).ceil * cooking_time + cooking_total_time + (rest_fish_time - (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time + (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time) * ((count - let_foodstuff_capacity) / let_foodstuff_capacity) + rest_fish_time - (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time + ((count % let_foodstuff_capacity) / cookware_capacity).ceil * cooking_time
rubocopを実行すると以下のようになります。
..........C.................... Offenses: app/forms/calculate_cooking_time.rb:41:13: C: [Correctable] Layout/MultilineOperationIndentation: Align the operands of an expression spanning multiple lines. ((count - let_foodstuff_capacity) / let_foodstuff_capacity) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ app/forms/calculate_cooking_time.rb:47:13: C: [Correctable] Layout/MultilineOperationIndentation: Align the operands of an expression spanning multiple lines. ((count - let_foodstuff_capacity) / let_foodstuff_capacity) + rest_fish_time - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 files inspected, 2 offenses detected, 2 offenses auto-correctable
試したこと
以下を試しました。
①
if (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time < rest_fish_time && ((count - let_foodstuff_capacity) % let_foodstuff_capacity).zero? ((let_foodstuff_capacity - cookware_capacity) / cookware_capacity).ceil * cooking_time + cooking_total_time + (rest_fish_time - (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time + (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time) * ((count - let_foodstuff_capacity) / let_foodstuff_capacity) elsif (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time < rest_fish_time && (count - let_foodstuff_capacity) % let_foodstuff_capacity != 0 ((let_foodstuff_capacity - cookware_capacity) / cookware_capacity).ceil * cooking_time + cooking_total_time + (rest_fish_time - (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time + (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time) * ((count - let_foodstuff_capacity) / let_foodstuff_capacity) + rest_fish_time - (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time + ((count % let_foodstuff_capacity) / cookware_capacity).ceil * cooking_time
..........C.................... Offenses: app/forms/calculate_cooking_time.rb:39:11: C: [Correctable] Layout/MultilineOperationIndentation: Use 2 (not 0) spaces for indenting an expression spanning multiple lines. cooking_total_time + (rest_fish_time - (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time + ^^^^^^^^^^^^^^^^^^ app/forms/calculate_cooking_time.rb:41:11: C: [Correctable] Layout/MultilineOperationIndentation: Align the operands of an expression spanning multiple lines. ((count - let_foodstuff_capacity) / let_foodstuff_capacity) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ app/forms/calculate_cooking_time.rb:45:11: C: [Correctable] Layout/MultilineOperationIndentation: Use 2 (not 0) spaces for indenting an expression spanning multiple lines. cooking_total_time + (rest_fish_time - (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time + ^^^^^^^^^^^^^^^^^^ app/forms/calculate_cooking_time.rb:47:11: C: [Correctable] Layout/MultilineOperationIndentation: Align the operands of an expression spanning multiple lines. ((count - let_foodstuff_capacity) / let_foodstuff_capacity) + rest_fish_time - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ app/forms/calculate_cooking_time.rb:48:11: C: [Correctable] Layout/MultilineOperationIndentation: Use 2 (not 0) spaces for indenting an expression spanning multiple lines. (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ app/forms/calculate_cooking_time.rb:49:11: C: [Correctable] Layout/MultilineOperationIndentation: Use 2 (not 0) spaces for indenting an expression spanning multiple lines. ((count % let_foodstuff_capacity) / cookware_capacity).ceil * cooking_time ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 files inspected, 6 offenses detected, 6 offenses auto-correctable
②
if (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time < rest_fish_time && ((count - let_foodstuff_capacity) % let_foodstuff_capacity).zero? ((let_foodstuff_capacity - cookware_capacity) / cookware_capacity).ceil * cooking_time + cooking_total_time + (rest_fish_time - (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time + (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time) * ((count - let_foodstuff_capacity) / let_foodstuff_capacity) elsif (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time < rest_fish_time && (count - let_foodstuff_capacity) % let_foodstuff_capacity != 0 ((let_foodstuff_capacity - cookware_capacity) / cookware_capacity).ceil * cooking_time + cooking_total_time + (rest_fish_time - (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time + (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time) * ((count - let_foodstuff_capacity) / let_foodstuff_capacity) + rest_fish_time - (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time + ((count % let_foodstuff_capacity) / cookware_capacity).ceil * cooking_time
..........C.................... Offenses: app/forms/calculate_cooking_time.rb:41:11: C: [Correctable] Layout/MultilineOperationIndentation: Align the operands of an expression spanning multiple lines. ((count - let_foodstuff_capacity) / let_foodstuff_capacity) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ app/forms/calculate_cooking_time.rb:47:11: C: [Correctable] Layout/MultilineOperationIndentation: Align the operands of an expression spanning multiple lines. ((count - let_foodstuff_capacity) / let_foodstuff_capacity) + rest_fish_time - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ app/forms/calculate_cooking_time.rb:48:12: C: [Correctable] Layout/MultilineOperationIndentation: Use 2 (not 1) spaces for indenting an expression spanning multiple lines. (let_foodstuff_capacity / cookware_capacity).ceil * cooking_time + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ app/forms/calculate_cooking_time.rb:49:12: C: [Correctable] Layout/MultilineOperationIndentation: Use 2 (not 1) spaces for indenting an expression spanning multiple lines. ((count % let_foodstuff_capacity) / cookware_capacity).ceil * cooking_time ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 files inspected, 4 offenses detected, 4 offenses auto-correctable
参考記事
https://techracho.bpsinc.jp/hachi8833/2016_12_16/31386
ご教示お願いします。
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
また依頼した内容が修正された場合は、修正依頼を取り消すようにしましょう。