Repository navigation
Professionalize repo: refactor, tests, CI, docs - #1
Merged
Merged
Conversation
Restructure the project around the standard cmd/ + internal/ layout and
strip the overengineering that accumulated in the original code.
Layout:
- Fix module path: ProxyRiskScoreChecker -> github.com/<owner>/ProxyRiskScoreChecker
- Move cmd/main/main.go -> cmd/proxyriskscore/main.go (binary name is the
meaningful name, not "main")
- Collapse internal/proxyvalidate + internal/riskscore into internal/proxy
and internal/ipqs respectively
- Delete internal/models (an interface defined where it's not consumed)
- Delete internal/logging (custom Logger / LogType / proxyLogger replaced
by log/slog from the stdlib)
- Inline types.go files into their implementations (small packages,
splitting types from impl was pure overhead)
Code quality:
- Drop the ProxyConverter interface (it was defined twice in two packages
and only ever wrapped a single fmt.Sprintf call)
- Drop unused method proxyvalidate.ValidateAndSaveProxies (dead code)
- Drop the compile-time interface assertion that paired with the dropped
models.ProxyValidator interface
- Inline the proxy URL building into Proxy.URL() method (single source of
truth)
- Use fmt.Errorf with %w throughout for proper error wrapping
- Replace os.Getenv("API_KEY") with explicit env lookup against
IPQS_API_KEY (descriptive name; breaking change is documented in the
README migration section)
CLI:
- Replace interactive stdin prompts with flag-based CLI:
--input, --output, --strictness, --api-key, --timeout, --help
- Handle flag.ErrHelp explicitly so --help exits 0 instead of 2
- Drop the intermediate validproxys.txt output file (it leaked an
internal validation step as a side effect)
Logging:
- Replace custom Logger interface and proxyLogger struct with
slog.New(slog.NewTextHandler(os.Stderr, nil)). The custom abstraction
added 50 lines of plumbing for what slog provides as a one-liner.
- internal/proxy: table-driven tests covering each supported input format and a separate matrix of invalid inputs that must error - internal/ipqs: httptest-backed tests for the happy path, upstream failure messages, non-200 HTTP responses, and malformed JSON The proxy.Validator path is not covered yet: it requires a fixture SOCKS5/HTTP proxy to test in isolation. Tracked in the README roadmap.
- .editorconfig: cross-editor whitespace and EOL rules, with Go set to tab indentation (matches gofmt) and YAML/JSON to 2-space - .golangci.yml: enable errcheck, govet, ineffassign, staticcheck, unused, gofmt, goimports, misspell, unconvert, prealloc, revive. Tests exempted from errcheck for ergonomic test setup - .gitignore: cover build/release/dist directories, tool output files, common editor noise, OS metadata, .env files
Two jobs on ubuntu-latest, both pinned to Go 1.24 with build cache: - build-test: gofmt verification (fails on any output), go vet, go build ./..., go test -race -count=1 ./... - lint: golangci-lint v1.62 via the official action The lint job runs in parallel to keep total wall time low.
Replace the previous framing ("validate the reliability, anonymity and
security of proxy servers... ensuring your proxy endpoints are not
blacklisted, associated with botnets, or otherwise flagged for malicious
activity") with a description of what the tool actually does: query the
IPQS reputation API for a batch of proxies and report each one's
returned fraud_score.
Add an explicit "intended use" framing (operators monitoring their own
proxy fleet's IPQS reputation) and an enumeration of the external
services contacted.
Restructure the document into Overview, Build, Usage, Quality and
Conventions sections, plus a Roadmap and a Migration section listing
the breaking changes vs the previous interactive-CLI version
(IPQS_API_KEY env var, flag-based interface, renamed output file,
dropped intermediate file).
Add CI / Go / License badges.
The project uses log/slog (added in 1.21) and otherwise only stdlib features available since Go 1.18, so 1.24 was an arbitrarily high target that broke older golangci-lint binaries (the linter refuses to analyze code targeting a Go version newer than itself). CI still runs against Go 1.24; 1.21 here is only the minimum supported version declared in go.mod.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Five atomic commits that bring the repo up to the same quality bar applied recently to
mullvad-socks5-probe: code refactor with clean-code/KISS/DRY/YAGNI passes, real unit tests, GitHub Actions CI, tooling configs, and a rewritten README with neutral framing.refactor: collapse to standard Go layout and simplify abstractionsFixes the module path to
github.com/<owner>/ProxyRiskScoreChecker, moves tocmd/proxyriskscore/+internal/proxy+internal/ipqs, deletes themodelsandloggingpackages and the duplicatedProxyConverterinterface, drops deadValidateAndSaveProxiescode, switches custom Logger tolog/slog, replaces interactive stdin prompts with flag-based CLI (--input,--output,--strictness,--api-key,--timeout), usesfmt.Errorf("%w", ...)throughout for proper error wrapping. Drops the intermediatevalidproxys.txtoutput.test: add unit tests for proxy parser and IPQS clientTable-driven tests for every supported input format in
proxy.Parseplus a matrix of invalid inputs.httptest-backed tests for the IPQS client covering happy path, upstream failure messages, non-200 HTTP, and malformed JSON.chore: add editorconfig, golangci config and expand gitignoreci: add GitHub Actions workflow for build, test, format and lintTwo jobs:
build-test(gofmt verify, vet, build, test -race) andlint(golangci-lint v1.62). Both pinned to Go 1.24 with build cache.docs(readme): rewrite with neutral framing, badges and migration notesReplaces the prior "validate the reliability, anonymity and security of proxy servers... not blacklisted, associated with botnets, or otherwise flagged for malicious activity" framing with an honest description of what the tool does (batch IPQS reputation lookups), plus an explicit intended-use framing (operators monitoring their own proxy fleet), an enumeration of external services contacted, usage examples, and a migration section listing all breaking changes vs the prior interactive version.
Breaking changes (all surfaced in the README migration section)
API_KEY->IPQS_API_KEY.proxies_risk_score_0.txt->clean.txt.validproxys.txtfile no longer written.Test plan
go build ./...clean at every commit (bisect-safe).go vet ./...clean.go test -race -count=1 ./...passes (8 test cases across 2 packages).gofmt -l .returns nothing.--helpexits 0, missing API key exits 2 with clear error, strictness validation rejects out-of-range values.