Skip to content

Commit

Permalink
DepShield: Navigate around multiple returns (#238)
Browse files Browse the repository at this point in the history
Sometimes calling `YAML.load_file` on an empty file returns `nil`. Other
times, it returns `false`. This accounts for both.
  • Loading branch information
that-jill authored Jan 31, 2024
1 parent a167201 commit f0bbbaf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/dep_shield/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ PATH
PATH
remote: .
specs:
dep_shield (0.1.1)
dep_shield (0.1.2)
nitro_config
rails (>= 6.0.6.1, < 7.0)
sentry-rails (= 5.5.0)
Expand Down
4 changes: 3 additions & 1 deletion packages/dep_shield/lib/dep_shield/todos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ def todo_list
paths = Rails.root.glob("**/.deprecation_todo.yml")

paths.each_with_object({}) do |path, list|
YAML.load_file(path)&.each do |feature_name, dep_todos|
todos = YAML.load_file(path) || {}

todos.each do |feature_name, dep_todos|
list[feature_name] ||= []
list[feature_name] += dep_todos
end
Expand Down
2 changes: 1 addition & 1 deletion packages/dep_shield/lib/dep_shield/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module DepShield
VERSION = "0.1.1"
VERSION = "0.1.2"
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Using NitroErrors to mark something as deprecated means that it may raise when
# new code using deprecated methods is introduced.
# This file can be used to whitelist preexisting methods so that they will not raise,
# and register a list of todos for places that should be fixed.
# The intention is for the user to remove these configuration records
# one by one as the deprecations are removed from the code base.
#
# More information: https://github.com/powerhome/nitro-web/blob/master/components/nitro_errors/docs/README.md#L1

# Example:
# test_deprecation_name:
# - app/controllers/example_controller.rb

0 comments on commit f0bbbaf

Please sign in to comment.