Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Orthoses::Constant to skip modules #88

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/orthoses/constant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def call
cache[[current, const]] = true

if val.kind_of?(Module)
next unless @if.nil? || @if.call(current, const, val, nil)
will_add_key_and_content << [Utils.module_name(val), nil]
next
end
Expand Down
3 changes: 2 additions & 1 deletion lib/orthoses/constant_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module Bar
end
class Baz
CONST = 3
IGNORE_ME = Class.new
end
end

Expand All @@ -21,7 +22,7 @@ def test_constant(t)
Orthoses::Utils.new_store.tap do |store|
store["ConstantTest"]
end
}, strict: true).call
}, strict: true, if: -> (current, const, val, rbs) { const.to_s != "IGNORE_ME" }).call

unless store.length == 8
t.error("expect 8 constant decls, but got #{store.length}")
Expand Down