MCPcopy Create free account
hub / github.com/FastLED/FastLED / coding_standards

Function coding_standards

mcp_server.py:865–1254  ·  view source on GitHub ↗

Provide FastLED coding standards and best practices.

(
    arguments: dict[str, Any], project_root: Path
)

Source from the content-addressed store, hash-verified

863
864
865async def coding_standards(
866 arguments: dict[str, Any], project_root: Path
867) -> CallToolResult:
868 """Provide FastLED coding standards and best practices."""
869 topic = arguments.get("topic", "all")
870
871 standards = {
872 "exceptions": """
873# Exception Handling Standards
874
875⚠️ **CRITICAL: DO NOT use try-catch blocks or C++ exception handling in FastLED code**
876
877## Why No Exceptions?
878FastLED is designed for embedded systems like Arduino where:
879- Exception handling may not be available
880- Exceptions consume significant memory and performance
881- Reliable operation across all platforms is required
882
883## What to Avoid:
884[ERROR] `try { ... } catch (const std::exception& e) { ... }`
885[ERROR] `throw std::runtime_error("error message")`
886[ERROR] `#include <exception>` or `#include <stdexcept>`
887
888## Use Instead:
889[OK] **Return error codes:** `bool function() { return false; }`
890[OK] **Optional types:** `fl::optional<T>`
891[OK] **Assertions:** `FL_ASSERT(condition)`
892[OK] **Early returns:** `if (!valid) return false;`
893[OK] **Status objects:** Custom result types
894
895## Examples:
896```cpp
897// Good: Using return codes
898bool initializeHardware() {
899 if (!setupPins()) {
900 FL_WARN("Failed to setup pins");
901 return false;
902 }
903 return true;
904}
905
906// Good: Using fl::optional
907fl::optional<float> calculateValue(int input) {
908 if (input < 0) {
909 return fl::nullopt;
910 }
911 return fl::make_optional(sqrt(input));
912}
913```
914""",
915 "std_namespace": """
916# Standard Library Namespace Standards
917
918⚠️ **DO NOT use std:: prefixed functions or headers**
919
920FastLED provides its own STL-equivalent implementations under the `fl::` namespace.
921
922## Common Replacements:

Callers 1

call_toolFunction · 0.85

Calls 3

itemsMethod · 0.80
getMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected