Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify Custom Vote #848

Merged
merged 1 commit into from
Nov 11, 2024
Merged

Modify Custom Vote #848

merged 1 commit into from
Nov 11, 2024

Conversation

Aidenkrz
Copy link
Contributor

@Aidenkrz Aidenkrz commented Nov 11, 2024

About the PR

image

Why / Balance

why not

Summary by CodeRabbit

  • New Features

    • Increased maximum number of arguments for custom vote commands from 10 to 31.
    • Enhanced logging for custom vote initiation, including title and options.
  • Bug Fixes

    • Adjusted argument validation for custom vote commands to require a minimum of 2 arguments.
    • Updated validation requirements for Votekick command to ensure exactly three arguments are provided.
  • Documentation

    • Improved error messages to reflect new argument limits and validation requirements.

Copy link
Contributor

coderabbitai bot commented Nov 11, 2024

Walkthrough

The changes in the VoteCommands.cs file involve updates to the CreateCustomCommand and CreateVoteCommand classes, focusing on argument validation and logging enhancements. The maximum allowed arguments for custom vote commands increased from 10 to 31, with the minimum required arguments adjusted from 3 to 2. Additionally, specific validations for the Votekick type were refined. Logging for custom vote initiation and completion was also improved for better tracking of vote actions. Overall, these modifications aim to enhance the functionality and clarity of vote commands.

Changes

File Path Change Summary
Content.Server/Voting/VoteCommands.cs - Increased MaxArgCount from 10 to 31 in CreateCustomCommand.
- Adjusted minimum argument requirement from 3 to 2.
- Updated validation for CreateVoteCommand for StandardVoteType.Votekick to require exactly 3 args.
- Enhanced logging in Execute method for custom vote initiation, completion, and cancellation.

Poem

In the land of votes, where choices abound,
A pounce of new limits, oh what joy found!
From ten to thirty-one, the arguments soar,
With logs that now sparkle, we’ll vote evermore!
So let’s raise our paws, for commands that are bright,
In the furry realm, everything feels just right! ✨🐾


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
Content.Server/Voting/VoteCommands.cs (2)

Line range hint 32-39: OwO notices your argument validation! nuzzles the code

The validation wogic looks good but could use some extra safety! paws at the code Maybe we should add some input sanitation for the votekick target? >w<

if (args.Length != 3 && args[0] == StandardVoteType.Votekick.ToString())
{
    shell.WriteError(Loc.GetString("shell-wrong-arguments-number-need-specific", ("properAmount", 3), ("currentAmount", args.Length)));
    return;
}
+ // Add validation for votekick target
+ if (args[0] == StandardVoteType.Votekick.ToString() && string.IsNullOrWhiteSpace(args[1]))
+ {
+     shell.WriteError(Loc.GetString("Invalid votekick target"));
+     return;
+ }

Line range hint 112-119: *pounces on your logging* Rawr x3

The logging is getting better! nuzzles the code But we could make it even more detailed! >w<

if (shell.Player != null)
-    _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"{shell.Player} initiated a custom vote: {options.Title} - {string.Join("; ", options.Options.Select(x => x.text))}");
+    _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"{shell.Player} initiated a custom vote: {options.Title} - {string.Join("; ", options.Options.Select(x => x.text))} with duration {options.Duration.TotalSeconds}s");
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5ce4652 and c73fc2a.

📒 Files selected for processing (1)
  • Content.Server/Voting/VoteCommands.cs (1 hunks)
🔇 Additional comments (2)
Content.Server/Voting/VoteCommands.cs (2)

82-82: *notices your big number* What's this? owo

The MaxArgCount of 31 seems weawwy high! boops the code This could make the vote UI messy and might be abused to spam chat! Maybe we should:

  1. Add a check for duplicate options
  2. Validate option lengths
  3. Consider a more reasonable limit? :3

Also applies to: 90-93


90-93: ⚠️ Potential issue

*notices potential security risk* owo what's this?

With the lowered minimum args (>﹏<) we should make sure players can't create misleading votes! worried paw gestures

Consider adding validation for:

  1. Minimum option length
  2. Restricted characters
  3. Rate limiting for non-admin votes

Also applies to: 112-119

@Aidenkrz Aidenkrz merged commit 89de65d into Goob-Station:master Nov 11, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant