Created
September 14, 2025 16:51
-
-
Save sakuro/0e632e5f6df2277231a427cdc47a5fc7 to your computer and use it in GitHub Desktop.
PLATFORMSに入っているべき値を強制するCop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # lib/rubocop/cop/bundler/required_platforms.rb | |
| module RuboCop | |
| module Cop | |
| module Bundler | |
| class RequiredPlatforms < Cop | |
| def on_new_investigation | |
| required = Array(cop_config['RequiredPlatforms']) | |
| lockfile = File.read('Gemfile.lock') | |
| platforms = lockfile[/^PLATFORMS\n(.+?)\n\n/m, 1].to_s.lines.map(&:strip) | |
| (required - platforms).each do |missing| | |
| add_offense(nil, message: "Gemfile.lock に #{missing} が含まれていません") | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment