From 0e1d6a9c221133fa2cc9977c61983111918d99ae Mon Sep 17 00:00:00 2001 From: nikitakar9862 Date: Mon, 6 Apr 2026 09:59:05 +0000 Subject: [PATCH 1/3] Add test for private method inheritance visibility --- spec/fixtures/private_inheritance.rb | 13 +++++++++++++ spec/units/visitors/method_call_visitor_spec.rb | 15 ++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/private_inheritance.rb diff --git a/spec/fixtures/private_inheritance.rb b/spec/fixtures/private_inheritance.rb new file mode 100644 index 0000000..92b5433 --- /dev/null +++ b/spec/fixtures/private_inheritance.rb @@ -0,0 +1,13 @@ +class Parent + private + + def greet + 'hello' + end +end + +class Child < Parent + def call_greet + greet + end +end \ No newline at end of file diff --git a/spec/units/visitors/method_call_visitor_spec.rb b/spec/units/visitors/method_call_visitor_spec.rb index 4929c0b..9701a3c 100644 --- a/spec/units/visitors/method_call_visitor_spec.rb +++ b/spec/units/visitors/method_call_visitor_spec.rb @@ -13,4 +13,17 @@ expect(file_proxy.dependencies).to eq(Set.new(['Lowkey::A::B'])) end end -end + + describe 'private method inheritance' do + let(:file_path) { 'spec/fixtures/private_inheritance.rb' } + let(:file_proxy) { Lowkey.load(file_path, cache: false) } + + it 'tracks private visibility correctly without leaking to subclass' do + parent = file_proxy["Parent"] + child = file_proxy["Child"] + + expect(parent.private_start_line).not_to be_nil + expect(child.private_start_line).to be_nil + end + end +end \ No newline at end of file From 3a8a96d464a3f20a3c6e6e0d07f2c6b00fec4931 Mon Sep 17 00:00:00 2001 From: nikitakar9862 Date: Mon, 20 Apr 2026 15:43:26 +0000 Subject: [PATCH 2/3] changed the inheritance test to visibility feature test per feedback --- spec/features/detects_private_method_spec.rb | 15 +++++++++++++++ spec/fixtures/private_inheritance.rb | 13 ------------- spec/fixtures/visibility_test.rb | 11 +++++++++++ spec/units/visitors/method_call_visitor_spec.rb | 13 ------------- 4 files changed, 26 insertions(+), 26 deletions(-) create mode 100644 spec/features/detects_private_method_spec.rb delete mode 100644 spec/fixtures/private_inheritance.rb create mode 100644 spec/fixtures/visibility_test.rb diff --git a/spec/features/detects_private_method_spec.rb b/spec/features/detects_private_method_spec.rb new file mode 100644 index 0000000..ecdae6a --- /dev/null +++ b/spec/features/detects_private_method_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require_relative '../../lib/lowkey' + +RSpec.describe 'Method Visibility Feature' do + let(:file_path) { 'spec/fixtures/visibility_test.rb' } + let(:file_proxy) { Lowkey.load(file_path, cache: false) } + + it 'detects that a class has private methods' do + target_class = file_proxy["VisibilityTest"] + + expect(target_class).not_to be_nil + expect(target_class.private_start_line).not_to be_nil + end +end \ No newline at end of file diff --git a/spec/fixtures/private_inheritance.rb b/spec/fixtures/private_inheritance.rb deleted file mode 100644 index 92b5433..0000000 --- a/spec/fixtures/private_inheritance.rb +++ /dev/null @@ -1,13 +0,0 @@ -class Parent - private - - def greet - 'hello' - end -end - -class Child < Parent - def call_greet - greet - end -end \ No newline at end of file diff --git a/spec/fixtures/visibility_test.rb b/spec/fixtures/visibility_test.rb new file mode 100644 index 0000000..9f43507 --- /dev/null +++ b/spec/fixtures/visibility_test.rb @@ -0,0 +1,11 @@ +class VisibilityTest + def public_greet + "hello" + end + + private + + def private_greet + "hello" + end +end \ No newline at end of file diff --git a/spec/units/visitors/method_call_visitor_spec.rb b/spec/units/visitors/method_call_visitor_spec.rb index 9701a3c..05b7be6 100644 --- a/spec/units/visitors/method_call_visitor_spec.rb +++ b/spec/units/visitors/method_call_visitor_spec.rb @@ -13,17 +13,4 @@ expect(file_proxy.dependencies).to eq(Set.new(['Lowkey::A::B'])) end end - - describe 'private method inheritance' do - let(:file_path) { 'spec/fixtures/private_inheritance.rb' } - let(:file_proxy) { Lowkey.load(file_path, cache: false) } - - it 'tracks private visibility correctly without leaking to subclass' do - parent = file_proxy["Parent"] - child = file_proxy["Child"] - - expect(parent.private_start_line).not_to be_nil - expect(child.private_start_line).to be_nil - end - end end \ No newline at end of file From 20519cd98c7c55d813833dfd1155345dd6c84b60 Mon Sep 17 00:00:00 2001 From: nikitakar9862 Date: Tue, 21 Apr 2026 13:58:12 +0000 Subject: [PATCH 3/3] Address review: fixed the formatting and cleanup spec --- spec/features/detects_private_method_spec.rb | 5 ++--- spec/fixtures/visibility_test.rb | 2 +- spec/units/visitors/method_call_visitor_spec.rb | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/features/detects_private_method_spec.rb b/spec/features/detects_private_method_spec.rb index ecdae6a..c9e2357 100644 --- a/spec/features/detects_private_method_spec.rb +++ b/spec/features/detects_private_method_spec.rb @@ -2,14 +2,13 @@ require_relative '../../lib/lowkey' -RSpec.describe 'Method Visibility Feature' do +RSpec.describe 'Private method visibility' do let(:file_path) { 'spec/fixtures/visibility_test.rb' } let(:file_proxy) { Lowkey.load(file_path, cache: false) } it 'detects that a class has private methods' do target_class = file_proxy["VisibilityTest"] - expect(target_class).not_to be_nil expect(target_class.private_start_line).not_to be_nil end -end \ No newline at end of file +end diff --git a/spec/fixtures/visibility_test.rb b/spec/fixtures/visibility_test.rb index 9f43507..50f6dfc 100644 --- a/spec/fixtures/visibility_test.rb +++ b/spec/fixtures/visibility_test.rb @@ -8,4 +8,4 @@ def public_greet def private_greet "hello" end -end \ No newline at end of file +end diff --git a/spec/units/visitors/method_call_visitor_spec.rb b/spec/units/visitors/method_call_visitor_spec.rb index 05b7be6..4929c0b 100644 --- a/spec/units/visitors/method_call_visitor_spec.rb +++ b/spec/units/visitors/method_call_visitor_spec.rb @@ -13,4 +13,4 @@ expect(file_proxy.dependencies).to eq(Set.new(['Lowkey::A::B'])) end end -end \ No newline at end of file +end