Skip to content

Add collector for Reigate and Banstead Borough Council#174

Open
moley-bot[bot] wants to merge 2 commits intomainfrom
collector/ReigateAndBansteadBoroughCouncil-issue-141-1771933166
Open

Add collector for Reigate and Banstead Borough Council#174
moley-bot[bot] wants to merge 2 commits intomainfrom
collector/ReigateAndBansteadBoroughCouncil-issue-141-1771933166

Conversation

@moley-bot
Copy link

@moley-bot moley-bot bot commented Feb 24, 2026

Summary

This PR adds a new bin collection data collector for Reigate and Banstead Borough Council.

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

Closes #141

Test Summary

 ==================== Test Summary ====================
 
 --------------------- Collector ----------------------
 
 Reigate and Banstead Borough Council
 
 ------------------- Addresses (23) -------------------
 
 - 10 Rose Bushes, Epsom Downs, KT17 3NX, 100061448981;10;Rose Bushes;Epsom Downs;Surrey;KT17 3NX;E05012881;51.317931919896;-0.23606113012646;31201203
 - 12 Rose Bushes, Epsom Downs, KT17 3NX, 100061448983;12;Rose Bushes;Epsom Downs;Surrey;KT17 3NX;E05012881;51.318011727054;-0.2359863161011;31201203
 - 14 Rose Bushes, Epsom Downs, KT17 3NX, 100061448985;14;Rose Bushes;Epsom Downs;Surrey;KT17 3NX;E05012881;51.318056016332;-0.23594156546559;31201203
 - 16 Rose Bushes, Epsom Downs, KT17 3NX, 100061448987;16;Rose Bushes;Epsom Downs;Surrey;KT17 3NX;E05012881;51.318109077022;-0.23588212766707;31201203
 - 18 Rose Bushes, Epsom Downs, KT17 3NX, 100061448988;18;Rose Bushes;Epsom Downs;Surrey;KT17 3NX;E05012881;51.318162353737;-0.2358370320499;31201203
 - ...
 
 --------------------- Bin Types ----------------------
 
 - Food Waste (Green Caddy)
 - Garden Waste (Brown)
 - Mixed Recycling (Grey)
 - Paper and Cardboard Recycling (Black Box)
 - Refuse (Green)
 
 -------------------- Bin Days (4) --------------------
 
 - 25/02/2026 (3 bins):
   - Food Waste (Green Caddy)
   - Garden Waste (Brown)
   - Paper and Cardboard Recycling (Black Box)
 
 - 04/03/2026 (4 bins):
   - Food Waste (Green Caddy)
   - Paper and Cardboard Recycling (Black Box)
   - Mixed Recycling (Grey)
   - Refuse (Green)
 
 - 11/03/2026 (3 bins):
   - Food Waste (Green Caddy)
   - Garden Waste (Brown)
   - Paper and Cardboard Recycling (Black Box)
 
 - 18/03/2026 (4 bins):
   - Food Waste (Green Caddy)
   - Paper and Cardboard Recycling (Black Box)
   - Mixed Recycling (Grey)
   - Refuse (Green)
 
 ======================================================

Bin Collections Page Screenshot

ReigateAndBansteadBoroughCouncil Bin Collections


Generated automatically by Moley-Bot using Codex CLI

Closes #141

Generated with Codex CLI by Moley-Bot
@moley-bot moley-bot bot added the new collector Request for a new collector to be supported label Feb 24, 2026
  Formatted by Moley-Bot
@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 PR adds a new collector for Reigate and Banstead Borough Council. The implementation is very complex, with the collector class exceeding 800 lines, which goes against the style guide's recommendation for simplicity. The main issue is the large, duplicated request bodies which should be refactored into a shared helper method. There are also several minor style guide violations, such as missing trailing commas and inconsistent use of modern C# features like collection expressions. Additionally, there's an inconsistency in metadata handling for derivable values, which should be addressed by deriving them locally rather than storing them in metadata. While the collector appears to be functional, addressing these points will significantly improve its maintainability.

/// <summary>
/// Builds the request body for the property details lookup.
/// </summary>
private static string BuildPropertyDetailsBody(Dictionary<string, string> metadata)

Choose a reason for hiding this comment

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

high

This collector is over 800 lines long, which significantly exceeds the 200-400 line recommendation in the style guide and indicates excessive complexity. A primary reason for this is the large amount of duplicated code between the BuildPropertyDetailsBody and BuildScheduleRequestBody methods. The JSON structure for formValues is almost identical in both.

To adhere to the DRY principle and improve maintainability, please extract the common JSON object structure into a dedicated helper method. This will significantly reduce the line count and make the collector easier to understand and maintain.

References
  1. Collectors should be simple, ideally 200-400 lines. Over 500 lines is a code smell indicating unnecessary complexity, often from bloated payloads or duplicated code. (link)
  2. Extract truly duplicated logic (used 2-3+ times) into helper methods to reduce duplication. (link)

Comment on lines +607 to +608
"lengthOfPostcode": { "value": "{{postcode.Length}}" },
"lengthMinus2": { "value": "{{postcode.Length - 2}}" },

Choose a reason for hiding this comment

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

medium

There's an inconsistency in how lengthOfPostcode and lengthMinus2 are handled. These values are stored in the metadata dictionary in GetBinDays (step 1), but this method recalculates them inline from the postcode variable. The BuildScheduleRequestBody method, however, uses the values from metadata. According to repository conventions, values that can be easily derived, such as these, should not be stored in metadata. To resolve this inconsistency and adhere to best practices, please remove lengthOfPostcode and lengthMinus2 from the metadata dictionary and ensure both BuildScheduleRequestBody and this method derive these values locally from the postcode variable.

References
  1. Only store metadata that is necessary for subsequent requests. Avoid storing values that can be easily derived. (link)
  2. In collectors, prioritize clarity by keeping the request flow for each method (e.g., GetAddresses, GetBinDays) self-contained, even if it introduces some code duplication for initial requests.

Comment on lines +65 to +66
Keys = [ "Garden waste" ],
},

Choose a reason for hiding this comment

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

low

According to the style guide, all multi-line initializers should have trailing commas. This helps with version control diffs and makes adding new items easier.

            Keys = [ "Garden waste" ],
        },
References
  1. Always use trailing commas in multi-line initializers to make future diffs cleaner and reduce merge conflicts. (link)

Comment on lines +155 to +156
{ "cookie", cookies },
{ "user-agent", Constants.UserAgent },

Choose a reason for hiding this comment

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

low

According to the style guide, all multi-line initializers should have trailing commas. This is missing here and in other header initializations throughout the file.

                    { "cookie", cookies },
                    { "user-agent", Constants.UserAgent },
References
  1. Always use trailing commas in multi-line initializers to make future diffs cleaner and reduce merge conflicts. (link)

var dateString = section.Groups["date"].Value.Trim();
var binsContent = section.Groups["content"].Value;

var binNames = BinNameRegex().Matches(binsContent)!.Select(match => match.Groups["bin"].Value.Trim()).ToList();

Choose a reason for hiding this comment

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

low

The style guide prefers using C# 12 collection expressions ([..]) over .ToList() for creating lists. Please update this line to use a collection expression for consistency.

                var binNames = [.. BinNameRegex().Matches(binsContent)!.Select(match => match.Groups["bin"].Value.Trim())];
References
  1. Use collection expressions ([.. collection]) instead of .ToList().AsReadOnly() or .ToList() for creating collections, as it is more concise modern C# 12 syntax. (link)

DateTimeStyles.None
);

var matchedBins = binNames.SelectMany(binName => ProcessingUtilities.GetMatchingBins(_binTypes, binName)).DistinctBy(bin => bin.Name).ToList();

Choose a reason for hiding this comment

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

low

The style guide prefers using C# 12 collection expressions ([..]) over .ToList() for creating lists. Please update this line to use a collection expression for consistency.

                var matchedBins = [.. binNames.SelectMany(binName => ProcessingUtilities.GetMatchingBins(_binTypes, binName)).DistinctBy(bin => bin.Name)];
References
  1. Use collection expressions ([.. collection]) instead of .ToList().AsReadOnly() or .ToList() for creating collections, as it is more concise modern C# 12 syntax. (link)

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.

Reigate and Banstead Borough Council

1 participant