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

GitHub Workflows & Rubocop #298

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -47,7 +47,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -60,6 +60,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require:
plugins:
- rubocop-performance
- rubocop-rake

Expand Down
20 changes: 4 additions & 16 deletions lib/discordrb/commands/command_bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def initialize(**attributes)
spaces_allowed: attributes[:spaces_allowed].nil? ? false : attributes[:spaces_allowed],

# Webhooks allowed to trigger commands
webhook_commands: attributes[:webhook_commands].nil? ? true : attributes[:webhook_commands],
webhook_commands: attributes[:webhook_commands].nil? || attributes[:webhook_commands],

channels: attributes[:channels] || [],

Expand Down Expand Up @@ -257,17 +257,9 @@ def arg_check(args, types = nil, server = nil)
next arg if types[i].nil? || types[i] == String

if types[i] == Integer
begin
Integer(arg, 10)
rescue ArgumentError
nil
end
Integer(arg, 10, exception: false)
elsif types[i] == Float
begin
Float(arg)
rescue ArgumentError
nil
end
Float(arg, exception: false)
elsif types[i] == Time
begin
Time.parse arg
Expand Down Expand Up @@ -295,11 +287,7 @@ def arg_check(args, types = nil, server = nil)
nil
end
elsif types[i] == Rational
begin
Rational(arg)
rescue ArgumentError
nil
end
Rational(arg, exception: false)
elsif types[i] == Range
begin
if arg.include? '...'
Expand Down
4 changes: 2 additions & 2 deletions lib/discordrb/commands/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def initialize(name, attributes = {}, &block)
channels: attributes[:channels] || nil,

# Whether this command is usable in a command chain
chain_usable: attributes[:chain_usable].nil? ? true : attributes[:chain_usable],
chain_usable: attributes[:chain_usable].nil? || attributes[:chain_usable],

# Whether this command should show up in the help command
help_available: attributes[:help_available].nil? ? true : attributes[:help_available],
help_available: attributes[:help_available].nil? || attributes[:help_available],

# Description (for help command)
description: attributes[:description] || nil,
Expand Down
2 changes: 2 additions & 0 deletions lib/discordrb/data/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -944,8 +944,10 @@ def link

private

# rubocop:disable Lint/UselessConstantScoping
# For bulk_delete checking
TWO_WEEKS = 86_400 * 14
# rubocop:enable Lint/UselessConstantScoping

# Deletes a list of messages on this channel using bulk delete.
def bulk_delete(ids, strict = false, reason = nil)
Expand Down
4 changes: 4 additions & 0 deletions lib/discordrb/gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,9 @@ def handle_error(e)
LOGGER.log_exception(e)
end

# rubocop:disable Lint/UselessConstantScoping
ZLIB_SUFFIX = "\x00\x00\xFF\xFF".b.freeze
# rubocop:enable Lint/UselessConstantScoping

def handle_message(msg)
case @compress_mode
Expand Down Expand Up @@ -794,7 +796,9 @@ def handle_internal_close(e)
# - 4004: Authentication failed. Token was wrong, nothing we can do.
# - 4011: Sharding required. Currently requires developer intervention.
# - 4014: Use of disabled privileged intents.
# rubocop:disable Lint/UselessConstantScoping
FATAL_CLOSE_CODES = [4003, 4004, 4011, 4014].freeze
# rubocop:enable Lint/UselessConstantScoping

def handle_close(e)
@bot.__send__(:raise_event, Events::DisconnectEvent.new(@bot))
Expand Down