Skip to content

Ai slop cleanup#82

Merged
evg4b merged 5 commits into
mainfrom
ai-slop-cleanup
May 16, 2026
Merged

Ai slop cleanup#82
evg4b merged 5 commits into
mainfrom
ai-slop-cleanup

Conversation

@evg4b
Copy link
Copy Markdown
Owner

@evg4b evg4b commented May 16, 2026

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring
  • Test update
  • Chore (dependency updates, CI/CD changes, etc.)

Related Issues

Motivation and Context

How Has This Been Tested?

  • Unit tests
  • Integration tests
  • Manual testing
  • Added new tests

Test Configuration:

  • Go version:
  • OS:
  • UNCORS version:

Screenshots (if applicable)

Checklist

Code Quality

  • My code follows the code style of this project
  • I have run make format to format my code
  • I have run golangci-lint run and resolved all issues
  • I have performed a self-review of my code
  • My code has no new warnings or errors

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have run make test and all tests pass
  • I have run make test-cover and maintained or improved code coverage

Documentation

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have updated the wiki if necessary
  • I have updated the JSON schema if configuration changes were made

Dependencies

  • My changes don't introduce new dependencies, or they are justified
  • I have run go mod tidy to clean up dependencies
  • All dependencies are compatible with the project's Go version

Breaking Changes

  • This PR contains breaking changes
  • I have updated the migration guide (if applicable)
  • I have clearly documented breaking changes in the PR description

Additional Notes

For Reviewers

Areas that need special attention:

Known issues or limitations:


By submitting this pull request, I confirm that my contribution is made under the terms of the MIT License and I have read and followed the Contributing Guidelines.

evg4b added 5 commits May 16, 2026 01:31
Bugs / Race conditions fixed

internal/tui/output.go — InfoBox/WarnBox/ErrorBox now acquire the write mutex before writing, eliminating a real data race with concurrent Info/Error/etc. calls.
internal/tui/output.go — defer o.buffer.Reset() replaced with a plain o.buffer.Reset() after the write; the deferred form left the buffer populated until function exit and would have skipped cleanup on panic.
Exported type typo corrected

internal/contracts/http.go — ReqestData → RequestData (missing 'u'). Propagated across all 13 callers: contracts/output.go, helpers/request_data.go, server/tracker.go, tui/output.go, tui/printresponse.go, both tui tests, server tests, uncors_app tests, and the regenerated testing/mocks/output_mock.go.
Other typos fixed

internal/tui/output.go — ouputType → outputType (unexported type)
internal/handler/mock/handler.go — waiteDelay → waitDelay
Dead / redundant code removed

internal/config/mapping.go — Deleted ValidateCacheGlob, which was a one-line alias for ValidateGlobPattern. Call sites updated to call ValidateGlobPattern directly.
internal/handler/uncors_handler.go — Removed the log.Printf duplicate that fired right after output.Errorf for the same message.
Performance fix

internal/urlreplacer/replacer.go — Built a subexpIndex map[string]int once at construction. Eliminated the O(n²) SubexpIndex call (linear scan per group per request) in Replace, replacing it with a O(1) map lookup.
Correctness / efficiency improvements

internal/handler/mock/handler.go — Simplified waitDelay: removed unnecessary for/break waitingLoop (the select fires exactly once), removed log.Printf calls. Also capped content-type sniffing to the first 512 bytes to avoid converting the full mock body to []byte.
internal/handler/rewrite/helpers.go — RewriteHostKey changed from var to const (prevents mutation; correct for a string context key).
Consistency

internal/config/cache_config.go — CacheGlobs.Clone() and CacheConfig.Methods clone now use slices.Clone instead of make+append.
internal/config/rewrite.go — RewriteOptions.Clone() now uses slices.Clone (all fields are value types); RewritingOption.Clone() simplified to return r.
@evg4b evg4b force-pushed the ai-slop-cleanup branch from 5aabc29 to f906a26 Compare May 16, 2026 15:22
@sonarqubecloud
Copy link
Copy Markdown

@evg4b evg4b marked this pull request as ready for review May 16, 2026 15:56
@evg4b evg4b merged commit 5eb69b0 into main May 16, 2026
9 checks passed
@evg4b evg4b deleted the ai-slop-cleanup branch May 16, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant