BLT icon indicating copy to clipboard operation
BLT copied to clipboard

Slack Bot : Reformat the file structure for better readability

Open Sarthak5598 opened this issue 10 months ago • 1 comments

Sarthak5598 avatar Feb 19 '25 18:02 Sarthak5598

@Sarthak5598, Can you tell me more about this issue?

rinkitadhana avatar Mar 11 '25 20:03 rinkitadhana

@coderabbitai can you please explain the issue

Krishiv-Mahajan avatar Nov 11 '25 15:11 Krishiv-Mahajan

[!TIP] For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Fetch the issue details from GitHub
gh issue view 3669 --repo OWASP-BLT/BLT --json number,title,body,labels,author,createdAt,state,comments --jq '.'

Length of output: 1065


🏁 Script executed:

#!/bin/bash
# Search for Slack Bot related files in the codebase
fd -t f -i slack

# Also search for files containing slack in their content to understand structure
rg -l --type py -i "slack" | head -20

Length of output: 1294


🏁 Script executed:

#!/bin/bash
# Check the structure of main Slack Bot files
echo "=== website/views/slackbot.py structure ==="
head -50 website/views/slackbot.py

echo -e "\n=== website/views/slack_handlers.py structure ==="
head -50 website/views/slack_handlers.py

echo -e "\n=== Checking line counts ==="
wc -l website/views/slackbot.py website/views/slack_handlers.py

Length of output: 3199


🏁 Script executed:

#!/bin/bash
# Get an overview of functions and classes in the Slack Bot files
echo "=== Functions/Classes in slackbot.py ==="
ast-grep --pattern 'def $FUNC($$$):
  $$$'  website/views/slackbot.py | grep -E "^def " | head -20

echo -e "\n=== Functions/Classes in slack_handlers.py ==="
ast-grep --pattern 'def $FUNC($$$):
  $$$' website/views/slack_handlers.py | grep -E "^def " | head -30

echo -e "\n=== Checking if there are class definitions ==="
rg -n "^class " website/views/slackbot.py website/views/slack_handlers.py

Length of output: 137


🏁 Script executed:

#!/bin/bash
# Get function definitions using grep
echo "=== Functions in slackbot.py ==="
grep -n "^def " website/views/slackbot.py

echo -e "\n=== Functions in slack_handlers.py ==="
grep -n "^def " website/views/slack_handlers.py | head -40

echo -e "\n=== Check decorators and structure ==="
rg -n "@(app\.|csrf_exempt)" website/views/slackbot.py website/views/slack_handlers.py | head -30

Length of output: 2130


@Krishiv-Mahajan Sure! Let me explain issue #3669.

Issue Overview

Title: Slack Bot : Reformat the file structure for better readability
Status: Open
Created by: @Sarthak5598

The Problem

While the issue doesn't have a detailed description, after analyzing the codebase, I can explain what needs to be done:

The Slack Bot code currently has poor file organization and structure:

Current Structure Issues:

  1. Massive file size: website/views/slack_handlers.py is 2,468 lines long - this is extremely difficult to navigate and maintain

  2. Poor separation of concerns: The slack_handlers.py file handles multiple different features all mixed together:

    • Slack events handling
    • Slack commands
    • GSoC project queries
    • OWASP chapter information
    • OWASP events
    • OWASP committees
    • User profile lookups
    • GitHub integrations
    • Pagination logic
  3. Code duplication: Functions like get_all_owasp_repos() and slack_commands() exist in both slackbot.py and slack_handlers.py

  4. Two main files with unclear responsibilities:

    • website/views/slackbot.py (394 lines) - uses slack_bolt framework
    • website/views/slack_handlers.py (2,468 lines) - uses slack_sdk

What Needs to Be Done

The issue is requesting a refactoring to improve readability by:

  • Breaking down the large slack_handlers.py file into smaller, focused modules
  • Organizing code by feature, for example:
    • slack/gsoc_handlers.py - GSoC project queries
    • slack/chapter_handlers.py - Chapter information
    • slack/event_handlers.py - Event handling
    • slack/committee_handlers.py - Committee information
    • slack/user_handlers.py - User profile lookups
    • slack/utils.py - Shared utilities
  • Removing code duplication
  • Creating a clear directory structure (e.g., website/views/slack/ or website/slack_bot/)
  • Improving maintainability and making it easier for contributors to find and modify specific features

This is a code organization/refactoring task that would significantly improve the codebase's readability and maintainability! 📚

coderabbitai[bot] avatar Nov 11 '25 15:11 coderabbitai[bot]