質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Circle CI

Circle CIは、クラウド上に簡単にCI環境を構築できるWebサービスです。GitHubと連携させ、CIしたいリポジトリーを選択しビルド・テストを行います。チャット等を利用して結果を確認することが可能です。

Q&A

解決済

1回答

1325閲覧

rubocopの範囲制限ができない

Engineer_traine

総合スコア17

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Circle CI

Circle CIは、クラウド上に簡単にCI環境を構築できるWebサービスです。GitHubと連携させ、CIしたいリポジトリーを選択しビルド・テストを行います。チャット等を利用して結果を確認することが可能です。

0グッド

0クリップ

投稿2021/08/09 12:37

前提・実現したいこと

circle clのran rubocopの箇所が通らない。
ローカルでbundle exec rubocopを行う際に警告が3500程出ていましたが自動修正のコマンドより450まで削減しました。
しかし残りの450程の解決を.rubocop.yamlに範囲制限を行い解消しようとかんがえましたがうまくいきません。
なにか原因等わかるかたいましたらよろしくお願いします。

発生している問題・エラーメッセージ

105 files inspected, 461 offenses detected

該当のソースコード

rails

1nherit_from: .rubocop_todo.yml 2 3require: 4 - rubocop-rails 5 - rubocop-rspec 6 - rubocop-performance 7 8AllCops: 9 TargetRubyVersion: 2.6 10 TargetRailsVersion: 5.2 11 Exclude: 12 - 'vendor/**/*' 13 - 'bin/**/*' 14 - 'db/**/*' 15 - 'tmp/**/*' 16 - 'node_modules/**/*' 17 - 'lib/tasks/auto_annotate_models.rake' 18 19Rails: 20 Enabled: true 21 22Rails/FilePath: 23 Exclude: 24 - 'lib/tasks/dev.rake' 25 - 'spec/rails_helper.rb' 26 27Style/AndOr: 28 Enabled: false 29 30Style/AsciiComments: 31 Enabled: false 32 33Layout/IndentationConsistency: 34 EnforcedStyle: indented_internal_methods 35 36Layout/CommentIndentation: 37 Enabled: false 38 39Layout/EmptyLinesAroundAttributeAccessor: 40 Enabled: true 41 42Layout/SpaceAroundMethodCallOperator: 43 Enabled: true 44 45Lint/DeprecatedOpenSSLConstant: 46 Enabled: true 47 48Lint/RaiseException: 49 Enabled: true 50 51Lint/StructNewOverride: 52 Enabled: true 53 54Layout/LineLength: 55 Max: 150 56 57Metrics/AbcSize: 58 Exclude: 59 - 'lib/tasks/dev.rake' 60 61Metrics/BlockLength: 62 CountComments: false 63 Exclude: 64 - 'Guardfile' 65 - 'config/routes.rb' 66 - 'spec/**/*' 67 - 'app/views/**/*.jbuilder' 68 - 'lib/tasks/dev.rake' 69 70Metrics/ClassLength: 71 CountComments: false 72 73Metrics/MethodLength: 74 CountComments: false 75 Max: 15 76 Exclude: 77 - 'lib/tasks/dev.rake' 78 79Metrics/ModuleLength: 80 CountComments: false 81 82Naming/FileName: 83 Exclude: 84 - 'Gemfile' 85 - 'Guardfile' 86 87Naming/MethodParameterName: 88 AllowedNames: [e] 89 90RSpec/ContextWording: 91 Enabled: false 92 93RSpec/DescribedClass: 94 Enabled: false 95 96RSpec/ExampleLength: 97 Enabled: false 98 99RSpec/ExpectInHook: 100 Enabled: false 101 102RSpec/InstanceVariable: 103 Enabled: false 104 105RSpec/MessageSpies: 106 Enabled: false 107 108RSpec/MultipleExpectations: 109 Enabled: false 110 111RSpec/NestedGroups: 112 Max: 5 113 114Style/BlockComments: 115 Exclude: 116 - 'spec/spec_helper.rb' 117 118Style/BlockDelimiters: 119 EnforcedStyle: braces_for_chaining 120 Exclude: 121 - 'spec/**/*' 122 123Style/ClassAndModuleChildren: 124 Enabled: false 125 126Style/Documentation: 127 Enabled: false 128 129Style/ExponentialNotation: 130 Enabled: true 131 132Style/HashEachMethods: 133 Enabled: true 134 135Style/HashTransformKeys: 136 Enabled: true 137 138Style/HashTransformValues: 139 Enabled: true 140 141Style/IfUnlessModifier: 142 Enabled: false 143 144Style/Lambda: 145 EnforcedStyle: literal 146 147Style/RegexpLiteral: 148 Enabled: false 149 150Style/SlicingWithRange: 151 Enabled: true

rails

1# This configuration was generated by 2# `rubocop --auto-gen-config` 3# on 2021-08-09 12:19:28 +0000 using RuboCop version 0.76.0. 4# The point is for the user to remove these configuration records 5# one by one as the offenses are removed from the code base. 6# Note that changes in the inspected code, or installation of new 7# versions of RuboCop, may require this file to be generated again. 8 9# Offense count: 1 10# Configuration parameters: Include. 11# Include: **/*.gemfile, **/Gemfile, **/gems.rb 12Bundler/DuplicatedGem: 13 Exclude: 14 - 'Gemfile' 15 16# Offense count: 1 17# Cop supports --auto-correct. 18# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. 19# SupportedStylesAlignWith: start_of_line, def 20Layout/DefEndAlignment: 21 Exclude: 22 - 'app/helpers/application_helper.rb' 23 24# Offense count: 1 25# Configuration parameters: AllowSafeAssignment. 26Lint/AssignmentInCondition: 27 Exclude: 28 - 'db/migrate/20210516054805_add_service_name_to_active_storage_blobs.active_storage.rb' 29 30# Offense count: 3 31Metrics/AbcSize: 32 Max: 915 33 34# Offense count: 4 35# Configuration parameters: CountComments, ExcludedMethods. 36# ExcludedMethods: refine 37Metrics/BlockLength: 38 Max: 1127 39 40# Offense count: 1 41# Configuration parameters: CountComments. 42Metrics/ClassLength: 43 Max: 1004 44 45# Offense count: 13 46# Configuration parameters: CountComments, ExcludedMethods. 47Metrics/MethodLength: 48 Max: 1002 49 50# Offense count: 2 51# Configuration parameters: AllowedChars. 52Style/AsciiComments: 53 Exclude: 54 - 'db/migrate/20190912232419_add_reset_password_token_index_to_spree_users.solidus_auth.rb' 55 56# Offense count: 2 57# Cop supports --auto-correct. 58# Configuration parameters: AutoCorrect, EnforcedStyle. 59# SupportedStyles: nested, compact 60Style/ClassAndModuleChildren: 61 Exclude: 62 - 'app/controllers/potepan/products_controller.rb' 63 - 'app/controllers/potepan/sample_controller.rb' 64 65# Offense count: 53 66Style/Documentation: 67 Enabled: false 68 69# Offense count: 7 70# Configuration parameters: MinBodyLength. 71Style/GuardClause: 72 Exclude: 73 - 'db/migrate/20180921154155_resize_api_key_field.spree_api.rb' 74 - 'db/migrate/20180921154158_create_users.solidus_auth.rb' 75 - 'db/migrate/20180921154161_add_reset_password_sent_at_to_spree_users.solidus_auth.rb' 76 - 'db/migrate/20190912232418_drop_spree_store_credit_update_reasons.spree.rb' 77 - 'db/migrate/20190912232419_add_reset_password_token_index_to_spree_users.solidus_auth.rb' 78 - 'db/migrate/20210325091636_add_unconfirmed_email_to_spree_users.solidus_auth.rb' 79 - 'db/migrate/20210516054805_add_service_name_to_active_storage_blobs.active_storage.rb' 80 81# Offense count: 9 82# Cop supports --auto-correct. 83Style/IfUnlessModifier: 84 Exclude: 85 - 'db/migrate/20180921154132_solidus_one_four.spree.rb' 86 - 'db/migrate/20180921154155_resize_api_key_field.spree_api.rb' 87 - 'db/migrate/20180921154161_add_reset_password_sent_at_to_spree_users.solidus_auth.rb' 88 - 'db/migrate/20190912232416_create_spree_store_credit_reasons_table.spree.rb' 89 - 'db/migrate/20190912232418_drop_spree_store_credit_update_reasons.spree.rb' 90 - 'db/migrate/20190912232419_add_reset_password_token_index_to_spree_users.solidus_auth.rb' 91 - 'db/migrate/20210325091636_add_unconfirmed_email_to_spree_users.solidus_auth.rb' 92 - 'spec/rails_helper.rb' 93 94# Offense count: 2 95Style/MixinUsage: 96 Exclude: 97 - 'bin/setup' 98 - 'bin/update' 99 100# Offense count: 371 101# Cop supports --auto-correct. 102# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. 103# URISchemes: http, https 104Metrics/LineLength: 105 Max: 307 106

試したこと

一応、最初からrubocopの導入の箇所からやり直しましたが制限の箇所で同様な結果になってしまいます。

補足情報(FW/ツールのバージョンなど)

mac os big sur ver11.5

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

範囲制限 って具体的にはどんなことを言ってます?
で、
何のためにrubocopを使おうと思ってます?

警告が出ないようにするために、rubocopの動きを変える、というのでしたら、rubocop使う意味が無いです。やめましょう。

使うのなら、
450 のうち、
なるほど、と思うものは指摘を満たすようにプログラムを直しましょう
言いたいことはわかるが、条件きびし過ぎない? と思うものは条件を緩めましょう。行数とかがそうです。
「なるほど」なんだけど、ここはもう手がない、というのでしたら、その部分を # rubocop: disable そのテスト# rubocop: enable そのテスト で囲んで目をつぶってもらいましょう

投稿2021/08/09 13:12

winterboum

総合スコア23416

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問