Skip to content

Comments

Add collector for Cheltenham Borough Council#135

Open
moley-bot[bot] wants to merge 2 commits intomainfrom
collector/CheltenhamBoroughCouncil-issue-131-1769857489
Open

Add collector for Cheltenham Borough Council#135
moley-bot[bot] wants to merge 2 commits intomainfrom
collector/CheltenhamBoroughCouncil-issue-131-1769857489

Conversation

@moley-bot
Copy link

@moley-bot moley-bot bot commented Jan 31, 2026

Summary

This PR adds a new bin collection data collector for Cheltenham Borough Council.

  • Implements ICollector interface
  • Adds integration tests
  • Successfully tested with example postcode from issue

Closes #131

Test Summary

 ==================== Test Summary ====================
 
 --------------------- Collector ----------------------
 
 Cheltenham Borough Council
 
 ------------------- Addresses (17) -------------------
 
 - 1 SPENSER ROAD CHELTENHAM CHELTENHAM GL51 7DU, GL51 7DU, 51363
 - 3 SPENSER ROAD CHELTENHAM CHELTENHAM GL51 7DU, GL51 7DU, 51374
 - 3 A SPENSER ROAD CHELTENHAM CHELTENHAM GL51 7DU, GL51 7DU, 5597
 - 5 SPENSER ROAD CHELTENHAM CHELTENHAM GL51 7DU, GL51 7DU, 51376
 - 7 SPENSER ROAD CHELTENHAM CHELTENHAM GL51 7DU, GL51 7DU, 51377
 - ...
 
 --------------------- Bin Types ----------------------
 
 - Food Waste (Green Caddy)
 - Garden Waste (Brown)
 - General Waste (Green)
 - Mixed Dry Recycling (Green Box) (Green Box)
 - Paper, Glass & Cardboard Recycling (Blue Bag) (Blue Bag)
 
 ------------------- Bin Days (78) --------------------
 
 - 03/02/2026 (3 bins):
   - Mixed Dry Recycling (Green Box) (Green Box)
   - Paper, Glass & Cardboard Recycling (Blue Bag) (Blue Bag)
   - Food Waste (Green Caddy)
 
 - 09/02/2026 (1 bins):
   - Garden Waste (Brown)
 
 - 10/02/2026 (2 bins):
   - General Waste (Green)
   - Food Waste (Green Caddy)
 
 - 17/02/2026 (3 bins):
   - Food Waste (Green Caddy)
   - Mixed Dry Recycling (Green Box) (Green Box)
   - Paper, Glass & Cardboard Recycling (Blue Bag) (Blue Bag)
 
 - 23/02/2026 (1 bins):
   - Garden Waste (Brown)
 
 - 24/02/2026 (2 bins):
   - General Waste (Green)
   - Food Waste (Green Caddy)
 
 - 03/03/2026 (3 bins):
   - Food Waste (Green Caddy)
   - Mixed Dry Recycling (Green Box) (Green Box)
   - Paper, Glass & Cardboard Recycling (Blue Bag) (Blue Bag)
 
 - 09/03/2026 (1 bins):
   - Garden Waste (Brown)
 
 - 10/03/2026 (2 bins):
   - General Waste (Green)
   - Food Waste (Green Caddy)
 
 - 17/03/2026 (3 bins):
   - Mixed Dry Recycling (Green Box) (Green Box)
   - Paper, Glass & Cardboard Recycling (Blue Bag) (Blue Bag)
   - Food Waste (Green Caddy)
 - ...
 
 ======================================================

Generated automatically by Moley-Bot using Codex CLI

@BadgerHobbs
Copy link
Owner

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new collector for Cheltenham Borough Council. While comprehensive, it has several security and reliability issues. The code is vulnerable to denial-of-service (DoS) attacks due to improper handling of malformed external responses in ParseJsonp and GetWeekStartDate. Missing URL encoding for client-side requests also poses a risk to functionality (e.g., with postcodes containing spaces) and security (potential parameter injection). Furthermore, the implementation is complex, particularly in the GetBinDays method, which exceeds recommended length, and exhibits code duplication and style guide deviations. Refactoring suggestions include creating helper methods for session/task logic, inlining constants, and improving collection/loop style.

@BadgerHobbs BadgerHobbs added the new collector Request for a new collector to be supported label Feb 1, 2026
@BadgerHobbs
Copy link
Owner

@claude Rebase onto main and update the integration test to the new format.

@moley-bot
Copy link
Author

moley-bot bot commented Feb 7, 2026

Claude finished @BadgerHobbs's task in 2m 13s —— View job


Task completed

Todo List

  • Read CLAUDE.md for repo-specific instructions
  • Rebase branch onto main
  • Read current integration test format
  • Find examples of new integration test format
  • Update integration test to new format
  • Commit and push changes

Summary

Successfully rebased the branch onto main and updated the integration test to the new format.

Changes made:

  1. Rebased onto main - The branch was completely out of sync with main (21 commits behind). Reset the branch to origin/main and reapplied only the collector implementation.
  2. Updated integration test format - Modified CheltenhamBoroughCouncilTests.cs to match the new format used in Refactor integration tests to use real API endpoints #145:
    • Removed _collector and _collectorService fields
    • Added _govUkId field that reads from the collector instance
    • Updated TestSteps.EndToEnd() call to use the new signature: _client, postcode, _govUkId, _outputHelper

The branch is now clean with a single commit on top of main, ready for review.

--- |

- Implements ICollector interface
- Adds integration test using new format
- Successfully tested with example postcode from issue

Co-authored-by: Andrew Riggs <BadgerHobbs@users.noreply.github.com>
@moley-bot moley-bot bot force-pushed the collector/CheltenhamBoroughCouncil-issue-131-1769857489 branch from 46dd180 to 9091b1c Compare February 7, 2026 20:32
@BadgerHobbs
Copy link
Owner

@claude Please fix all unresolved PR comments, making sure to test after each change made. Please include the test output in your final comment update.

@moley-bot
Copy link
Author

moley-bot bot commented Feb 18, 2026

Claude finished @BadgerHobbs's task in 4m 55s —— View job


Task completed

Todo List

  • Read current file and understand the code structure
  • Fix bin type names (remove type/color from names)
  • Fix raw string literal indentation
  • Inline single-use _calendarUrl constant
  • Add GeneratedRegex for HTML bold tag stripping (instead of string Replace)
  • Add ParseJsonp bounds validation (DoS fix)
  • Add GetWeekStartDate colon validation (DoS fix)
  • Add trailing comma on last bin type
  • Extract shared CreateSessionRequest helper method (used in both GetAddresses and GetBinDays)
  • Inline ParseDayOfWeek single-use helper into BuildCollectionDates
  • Refactor duplicate foreach loops into single combined loop
  • Build and test
  • Commit and push changes

Summary

All PR review comments have been addressed:

BadgerHobbs's comments:

  • Line 39 — Removed type/color suffixes from bin names: Mixed Dry Recycling (was Mixed Dry Recycling (Green Box)), Paper, Glass & Cardboard Recycling (was ... (Blue Bag)), Food Waste (was Food Waste (Green Caddy))
  • Line 79 — Inlined single-use _calendarUrl constant directly into the request
  • Line 139 — Replaced string.Replace HTML tag stripping with [GeneratedRegex(@"</?b>")] (class is now sealed partial)
  • Line 167 — The 11-request chain is inherent to the StatMap Aurora API, but extracted CreateSessionRequest helper to reduce duplication
  • Line 523 — Fixed raw string literal indentation (content now aligned with method body using tabs)
  • Line 772 — Inlined ParseDayOfWeek single-use helper into BuildCollectionDates

Gemini's comments (security/medium priority):

  • Line 720 — Added bounds validation to ParseJsonp: checks startIndex == -1 || endIndex == -1 || endIndex <= startIndex before slicing
  • Line 843 — Added !startLine.Contains(':') check before Split(':', 2)[1] in GetWeekStartDate
  • Line 63 — Added trailing comma after last bin type in _binTypes
  • Line 699 — Refactored 3 duplicate foreach loops into a single loop over (dates, bins) tuples
  • Line 188 — Extracted CreateSessionRequest(int requestId) helper, used in both GetAddresses and GetBinDays

Test Output

==================== Test Summary ====================

--------------------- Collector ----------------------

Cheltenham Borough Council

------------------- Addresses (17) -------------------

- 1 SPENSER ROAD CHELTENHAM CHELTENHAM GL51 7DU, GL51 7DU, 51363
- 3 SPENSER ROAD CHELTENHAM CHELTENHAM GL51 7DU, GL51 7DU, 51374
- 3 A SPENSER ROAD CHELTENHAM CHELTENHAM GL51 7DU, GL51 7DU, 5597
- 5 SPENSER ROAD CHELTENHAM CHELTENHAM GL51 7DU, GL51 7DU, 51376
- 7 SPENSER ROAD CHELTENHAM CHELTENHAM GL51 7DU, GL51 7DU, 51377
- ...

--------------------- Bin Types ----------------------

- Food Waste (Green Caddy)
- Garden Waste (Brown)
- General Waste (Green)
- Mixed Dry Recycling (Green Box)
- Paper, Glass & Cardboard Recycling (Blue Bag)

------------------- Bin Days (78) --------------------

- 23/02/2026 (1 bins):
  - Garden Waste (Brown)

- 24/02/2026 (2 bins):
  - General Waste (Green)
  - Food Waste (Green Caddy)

- 03/03/2026 (3 bins):
  - Food Waste (Green Caddy)
  - Mixed Dry Recycling (Green Box)
  - Paper, Glass & Cardboard Recycling (Blue Bag)

- 09/03/2026 (1 bins):
  - Garden Waste (Brown)

- ...

======================================================

Total tests: 1
     Passed: 1

|

- Remove bin type/color suffixes from bin names (Green Box, Blue Bag, Green Caddy)
- Add trailing comma on last bin type
- Inline single-use _calendarUrl constant
- Replace string Replace calls with GeneratedRegex for HTML bold tag stripping
- Add GeneratedRegex (make class partial)
- Fix raw string literal indentation in job JSON bodies
- Add ParseJsonp bounds validation to prevent InvalidOperationException on malformed JSONP
- Add GetWeekStartDate colon validation before Split to prevent IndexOutOfRangeException
- Extract CreateSessionRequest helper method (used in both GetAddresses and GetBinDays)
- Inline ParseDayOfWeek single-use helper method into BuildCollectionDates
- Refactor duplicate foreach loops into single combined loop over service tuples

Co-authored-by: Andrew Riggs <BadgerHobbs@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new collector Request for a new collector to be supported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cheltenham Borough Council

1 participant