[Duplicate Code] Share network configuration mock setup across network tests
Maintainers usually reply within 1 day
Assessment
This issue has not been assessed yet.
Description
Duplicate Code Opportunity
Summary
-
Pattern: The normal and uncovered-branches network test suites repeat the same mocked module aliases and
setupNetworkConfigMocksinitialization. -
Locations: File(s) and line ranges containing duplicates
src/commands/network-setup-branches.test.ts: lines 27-43src/commands/network-setup.test.ts: lines 20-36
-
Impact: This is security-sensitive network configuration test scaffolding. Duplicated mock wiring can drift, causing branch tests to exercise different resolver/logger behavior and increasing maintenance burden.
Evidence
src/commands/network-setup-branches.test.ts lines 27-43:
const mockedNetworkLogger = logger as jest.Mocked<typeof logger>;
const mockedDnsResolver = dnsResolver as jest.Mocked<typeof dnsResolver>;
const mockedUpstreamProxy = upstreamProxy as jest.Mocked<typeof upstreamProxy>;
const mockedOptionParsers = optionParsers as jest.Mocked<typeof optionParsers>;
describe('resolveNetworkConfig – uncovered branches', () => {
let processExitSpy: jest.SpyInstance;
beforeEach(() => {
processExitSpy = setupNetworkConfigMocks({
detectHostDnsServers: mockedDnsResolver.detectHostDnsServers as jest.Mock,
src/commands/network-setup.test.ts lines 20-36:
const mockedLogger = logger as jest.Mocked<typeof logger>;
const mockedDnsResolver = dnsResolver as jest.Mocked<typeof dnsResolver>;
const mockedUpstreamProxy = upstreamProxy as jest.Mocked<typeof upstreamProxy>;
const mockedOptionParsers = optionParsers as jest.Mocked<typeof optionParsers>;
describe('resolveNetworkConfig', () => {
let processExitSpy: jest.SpyInstance;
beforeEach(() => {
processExitSpy = setupNetworkConfigMocks({
detectHostDnsServers: mockedDnsResolver.detectHostDnsServers as jest.Mock,
Suggested Refactoring
Move the shared mocked-module declarations and beforeEach setup into a reusable test helper, or consolidate the branch coverage into the main network setup suite. Parameterize only the suite description and branch-specific behavior.
Affected Files
src/commands/network-setup-branches.test.ts— lines 27-43src/commands/network-setup.test.ts— lines 20-36
Effort Estimate
Low
Detected by Duplicate Code Detector workflow. Run date: 2026-10-21
Generated by Duplicate Code Detector · copilot · gpt54mini · 1.03 AIC · ⊞ 29.8K · ◷
- expires on Nov 20, 2026, 9:53 PM UTC
- Dominant language
- TypeScript
- Stars
- 150
- Forks
- 76
- Avg merge
- 4h 11m
- Merged PRs (30d)
- 463
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from github/gh-aw-firewall
-
agentic-workflows automated dependencies
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
github/gh-aw-firewall#3837 ·
Maintainers usually reply within 1 day
-
agentic-workflows
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
github/gh-aw-firewall#10471 ·
Maintainers usually reply within 1 day
-
agentic-workflows
Difficulty 4/5 1-2 days Newbie friendliness 25/100
github/gh-aw-firewall#10465 · 1 comment ·
Maintainers usually reply within 1 day
-
copilot-token-optimization
Difficulty 4/5 3-5 days Newbie friendliness 45/100
github/gh-aw-firewall#10454 ·
Maintainers usually reply within 1 day
-
token-usage-report
Difficulty 5/5 Over a week Newbie friendliness 1/100
github/gh-aw-firewall#10452 ·
Maintainers usually reply within 1 day
All issues in github/gh-aw-firewall
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Automattic/data-liberation-agent#953 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 90/100
funmary-app/funmary#399 ·
Maintainers usually reply within 1 day
-
area:curator enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
CassioDalla/Scrinalia#150 ·
Maintainers usually reply within 1 day
-
status: needs-triage v1-bug-bash
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
a2ui-project/a2ui#3533 ·
Maintainers usually reply within 1 day
-
backend enhancement priority:P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
geolens-io/geolens#3310 ·
Maintainers usually reply within 1 day