reactive-firewall / multicast

The multicast package is a Python library that simplifies sending and receiving multicast network messages. It provides classes and tools for implementing multicast communication in Python applications, making it straightforward to work with multicast sockets.
Other
2 stars 0 forks source link

v2.0.x Chore - add custom ast-grep rules #207

Open reactive-firewall opened 1 day ago

reactive-firewall commented 1 day ago
🔇 Additional comments (1)
docs/FAQ.md (1) `124-140`: **Verify Python API examples** Let's verify that the API examples are up-to-date with the current implementation.
✅ Verification successful **API examples are correct but could be improved** The Python API examples in the FAQ are accurate and match the implementation, as they use the correct class (`McastDispatch`) and method (`doStep`) with proper argument structure. However, the examples could be enhanced by: - Adding error handling with try-except blocks (already present) - Including comments about default values (port=59259, group='224.0.0.1') - Mentioning that the message argument is required - Documenting that the function returns a tuple of (success_bool, result)
🏁 Scripts executed The following scripts were executed for the analysis: Script: ```shell #! /bin/bash # Description: Verify Python API examples match the implementation # Test: Check if the API classes and methods exist ast-grep --pattern $'class McastRECV { $$$ doStep($$$) { $$$ } }' ast-grep --pattern $'class McastHEAR { $$$ doStep($$$) { $$$ } }' ``` Length of output: 153 --- Script: ```shell #!/bin/bash # Let's check for the actual McastDispatch class and its methods ast-grep --pattern $'class McastDispatch { $$$ doStep($$$) { $$$ } }' # Search for any Python files that might contain the implementation fd -e py --exec cat {} # Look for specific imports and usage patterns rg "class Mcast" -A 5 ``` Length of output: 270032 --- Script: ```shell #!/bin/bash # Let's check for McastDispatch.doStep implementation ast-grep --pattern $'class McastDispatch { $$$ doStep($$$) { $$$ } }' # Let's verify the example's SAY arguments match the implementation rg "McastDispatch\(\)\.doStep\(\[\"SAY\"," -A 2 ``` Length of output: 838 --- Script: ```shell #!/bin/bash # Let's check the actual implementation of McastSAY class ast-grep --pattern $'class McastSAY { $$$ doStep($$$) { $$$ } }' # Let's also check for any port/group validation in the code rg "port.*=.*kwargs\.get.*" -A 2 rg "group.*=.*kwargs\.get.*" -A 2 ``` Length of output: 936

Originally posted by @coderabbitai[bot] in https://github.com/reactive-firewall/multicast/pull/184#pullrequestreview-2446690171

reactive-firewall commented 1 day ago

also consider:

#! /bin/bash
# Description: Verify the method implementation and its usage across the codebase

# Check for the new method implementation
ast-grep --pattern $'def _should_get_package_version_WHEN_valid(self):
  $$$'

# Check for any remaining old method calls
rg '_get_package_version\(' --type py
reactive-firewall commented 1 day ago

also consider:

#! /bin/bash

# Check for other test files that might conflict or complement this test suite
printf "Checking for related test files...\n"
fd -t f -e py "test_.*server.*\.py$" tests/

# Look for McastServer usage across the codebase
printf "\nChecking McastServer usage...\n"
rg -l "class McastServer"

# Check for potential test gaps by looking for untested methods
printf "\nChecking for potentially untested server methods...\n"
ast-grep --pattern 'class McastServer {
  $$$
  def $METHOD($$$) {
    $$$
  }
  $$$
}'