Skip to content

Commit

Permalink
fix: misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anna328p committed Dec 26, 2023
1 parent e693b67 commit 393298c
Show file tree
Hide file tree
Showing 16 changed files with 416 additions and 309 deletions.
13 changes: 11 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@ AllCops:
NewCops: enable
ActiveSupportExtensionsEnabled: true

Layout/LineLength:
Max: 80
Layout/ArgumentAlignment:
EnforcedStyle: with_fixed_indentation

Layout/EndAlignment:
EnforcedStyleAlignWith: variable

Layout/FirstArgumentIndentation:
EnforcedStyle: consistent

Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent

Layout/LineLength:
Max: 80

Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented

Expand Down
6 changes: 2 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ gem 'rake'
# Base
gem 'discordrb', github: 'shardlab/discordrb', branch: 'main'
# dirty hack to fix bundix problems
gem 'discordrb-webhooks',
github: 'anna328p/discordrb',
branch: 'main'
gem 'discordrb-webhooks', github: 'anna328p/discordrb', branch: 'main'

gem 'rbnacl'

Expand Down Expand Up @@ -90,4 +88,4 @@ group :development do
end

# Colors
gem 'numo-narray'
gem 'matrix'
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ GEM
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
matrix (0.4.2)
mediawiki_api (0.8.1)
faraday (~> 1)
faraday-cookie_jar
Expand All @@ -154,7 +155,6 @@ GEM
nokogiri (1.15.5)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
numo-narray (0.9.2.1)
open_uri_redirections (0.2.1)
opus-ruby (1.0.1)
ffi
Expand Down Expand Up @@ -183,7 +183,7 @@ GEM
ffi (~> 1.0)
rbnacl (7.1.1)
ffi
rbs (3.3.2)
rbs (3.4.0)
abbrev
regexp_parser (2.8.3)
reline (0.4.1)
Expand Down Expand Up @@ -250,7 +250,7 @@ GEM
thor (~> 1.0)
tilt (~> 2.0)
yard (~> 0.9, >= 0.9.24)
sorbet-runtime (0.5.11156)
sorbet-runtime (0.5.11164)
sqlite3 (1.6.9)
mini_portile2 (~> 2.8.0)
steep (1.6.0)
Expand Down Expand Up @@ -286,8 +286,8 @@ GEM
tty-cursor (~> 0.7)
tty-screen (~> 0.8)
unicode-display_width (>= 1.6, < 3.0)
tty-screen (0.8.1)
typeprof (0.21.8)
tty-screen (0.8.2)
typeprof (0.21.9)
rbs (>= 1.8.1)
typhoeus (1.4.1)
ethon (>= 0.9.0)
Expand Down Expand Up @@ -319,10 +319,10 @@ DEPENDENCIES
jsi
kramdown
kramdown-parser-gfm
matrix
mediawiki_api
narray
nokogiri
numo-narray
open_uri_redirections
paint
parser
Expand Down
11 changes: 11 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative '../lib/qbot'

QBot.init_log
QBot.parse_options(ARGV)
QBot.init_config
QBot::Database.init_db

binding.irb

Check warning on line 11 in bin/console

View check run for this annotation

Check Run Reporter / Lint / lint

com.puppycrawl.tools.checkstyle.Lint/Debugger

com.puppycrawl.tools.checkstyle.Lint/Debugger: Lint/Debugger: Remove debugger entry point `binding.irb`.
23 changes: 13 additions & 10 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ rec {
in
genAttrs systems.flakeExposed;

qbotPkgArgs = pkgs: rec {
mkQBotArgs = pkgs: rec {
ruby = pkgs.ruby_3_2;
bundler = pkgs.bundler.override { inherit ruby; };
bundix = pkgs.bundix.override { inherit bundler; };

# TODO: remove once nixpkgs#272969 is merged
rustc = rust-overlay.packages.${pkgs.system}.rust;
Expand All @@ -47,7 +45,14 @@ rec {
config.allowUnfree = true;
};

qbot = pkgs.callPackage ./. (qbotPkgArgs pkgs);
qbotArgs = mkQBotArgs pkgs;

inherit (qbotArgs) ruby;

bundler = pkgs.bundler.override { inherit ruby; };
bundix = pkgs.bundix.override { inherit bundler; };

qbot = pkgs.callPackage ./. qbotArgs;
};

# withCommon : (Dict Any -> Dict Any) -> Dict (Dict Any)
Expand All @@ -56,14 +61,14 @@ rec {
in {
overlays = rec {
qbot = final: prev: {
qbot = final.callPackage ./. (qbotPkgArgs final);
qbot = final.callPackage ./. (mkQBotArgs final);
};

default = qbot;
};

nixosModules = rec {
qbot = import ./module.nix { inherit nixConfig; };
qbot = import nix/module.nix { inherit nixConfig; };
default = qbot;
};

Expand All @@ -83,14 +88,12 @@ rec {
});

apps = withCommon (env: let
inherit (env) pkgs;

pkgArgs = qbotPkgArgs pkgs;
inherit (env) pkgs bundler bundix;

update-deps = pkgs.writeShellApplication {
name = "update-deps";

runtimeInputs = [ pkgArgs.bundler pkgArgs.bundix ];
runtimeInputs = [ bundler bundix ];

text = ''
rm -f Gemfile.lock
Expand Down
38 changes: 18 additions & 20 deletions gemset.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion lib/qbot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
require_relative 'qbot/db_config'
require_relative 'qbot/db'
require_relative 'qbot/jobs'
require_relative 'qbot/index_models'
require_relative 'qbot/i18n'
require_relative 'qbot/helpers'
require_relative 'qbot/colorlib'
Expand Down
2 changes: 2 additions & 0 deletions lib/qbot/aur.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
url = "https://aur.archlinux.org/packages-meta-ext-v1.json.gz"

Check warning on line 1 in lib/qbot/aur.rb

View check run for this annotation

Check Run Reporter / Lint / lint

com.puppycrawl.tools.checkstyle.Lint/UselessAssignment

com.puppycrawl.tools.checkstyle.Lint/UselessAssignment: Lint/UselessAssignment: Useless assignment to variable - `url`.

Check warning on line 1 in lib/qbot/aur.rb

View check run for this annotation

Check Run Reporter / Lint / lint

com.puppycrawl.tools.checkstyle.Style/FrozenStringLiteralComment

com.puppycrawl.tools.checkstyle.Style/FrozenStringLiteralComment: Style/FrozenStringLiteralComment: Missing frozen string literal comment.

Check warning on line 1 in lib/qbot/aur.rb

View check run for this annotation

Check Run Reporter / Lint / lint

com.puppycrawl.tools.checkstyle.Style/StringLiterals

com.puppycrawl.tools.checkstyle.Style/StringLiterals: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

Check warning on line 2 in lib/qbot/aur.rb

View check run for this annotation

Check Run Reporter / Lint / lint

com.puppycrawl.tools.checkstyle.Layout/TrailingEmptyLines

com.puppycrawl.tools.checkstyle.Layout/TrailingEmptyLines: Layout/TrailingEmptyLines: 1 trailing blank lines detected.
2 changes: 0 additions & 2 deletions lib/qbot/db/concerns/configurable/option_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ def initialize(format: nil)
end

def format_value(value)
return t('types.empty') unless value

if @format
Kernel.format(FORMATS[@format], value)
else
Expand Down
11 changes: 10 additions & 1 deletion modules/colors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,12 @@ def self.create_color_roles(server, lightness, radius, count, &)
rescue ActiveRecord::RecordNotFound
embed t('colors.extra-roles.del.not-found', role.mention)
end
end
# rubocop: enable Metrics/ModuleLength

## Event container for the Colors module
module ColorsEvents
extend Discordrb::EventContainer

# Color roles on join

Expand Down Expand Up @@ -341,4 +347,7 @@ def give_random_color(server, user)
nil
end
end
# rubocop: enable Metrics/ModuleLength

module Colors

Check warning on line 351 in modules/colors.rb

View check run for this annotation

Check Run Reporter / Lint / lint

com.puppycrawl.tools.checkstyle.Style/Documentation

com.puppycrawl.tools.checkstyle.Style/Documentation: Style/Documentation: Missing top-level documentation comment for `module Colors`.
include! ColorsEvents
end
8 changes: 8 additions & 0 deletions modules/polls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def self.poll_allowed?(event, channel)

nil
end
end

module PollsEvents

Check warning on line 90 in modules/polls.rb

View check run for this annotation

Check Run Reporter / Lint / lint

com.puppycrawl.tools.checkstyle.Style/Documentation

com.puppycrawl.tools.checkstyle.Style/Documentation: Style/Documentation: Missing top-level documentation comment for `module PollsEvents`.
extend Discordrb::EventContainer

reaction_add do |event|
footer_text = event.message.embeds.first&.footer&.text
Expand All @@ -103,3 +107,7 @@ def self.poll_allowed?(event, channel)
end
end
end

module Polls

Check warning on line 111 in modules/polls.rb

View check run for this annotation

Check Run Reporter / Lint / lint

com.puppycrawl.tools.checkstyle.Style/Documentation

com.puppycrawl.tools.checkstyle.Style/Documentation: Style/Documentation: Missing top-level documentation comment for `module Polls`.
include! PollsEvents
end
8 changes: 8 additions & 0 deletions modules/tio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def self.get_codespans(text)

embed langs.keys.join(', ').truncate(2048)
end
end

module TioEvents

Check warning on line 59 in modules/tio.rb

View check run for this annotation

Check Run Reporter / Lint / lint

com.puppycrawl.tools.checkstyle.Style/Documentation

com.puppycrawl.tools.checkstyle.Style/Documentation: Style/Documentation: Missing top-level documentation comment for `module TioEvents`.
extend Discordrb::EventContainer

reaction_add(emoji: '❌') do |event|
if (ftext = event.message.embeds.first&.footer&.text) \
Expand All @@ -67,3 +71,7 @@ def self.get_codespans(text)
end
end
end

module Tio

Check warning on line 75 in modules/tio.rb

View check run for this annotation

Check Run Reporter / Lint / lint

com.puppycrawl.tools.checkstyle.Style/Documentation

com.puppycrawl.tools.checkstyle.Style/Documentation: Style/Documentation: Missing top-level documentation comment for `module Tio`.
include! TioEvents
end
File renamed without changes.
14 changes: 7 additions & 7 deletions scripts/compare_locales.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,33 +122,33 @@ def val(node)
# Filter for method calls
next unless node.type == :send

line = node.loc.line
col = node.loc.column
loc = KeyLoc.new(path:, line: node.loc.line, col: node.loc.column)

case node.children
# Find invocations of t()
in [_, :t, key, *]
list << KeyLoc.new(path:, line:, col:, key: val(key))
loc.key = val(key)

# Find all bot commands
in [_, :command, name, *]
list << KeyLoc.new(path:, line:, col:, key: "descriptions.#{val name}")
loc.key = "descriptions.#{val(name)}"

# Find list of locales
in [[[:const, _, :I18n], :config], :available_locales=, [*, locales]]
list << KeyLoc.new(path:, line:, col:, key: "locales.#{val name}")
loc.key = "locales.#{val(name)}"

else next
end

list << loc
}
}.inject(:+)

# print translations used in code, but not present in the base file.

puts Paint["Translations missing from #{base_name}:", :yellow, :bright]

key_groups = \
key_matches
key_groups = key_matches

Check warning on line 151 in scripts/compare_locales.rb

View check run for this annotation

Check Run Reporter / Lint / lint

com.puppycrawl.tools.checkstyle.Layout/RedundantLineBreak

com.puppycrawl.tools.checkstyle.Layout/RedundantLineBreak: Layout/RedundantLineBreak: Redundant line break detected.
.reject { base_flat.keys.include? _1.key }
.group_by(&:key)

Expand Down
Loading

0 comments on commit 393298c

Please sign in to comment.