rubocopping

This commit is contained in:
Cameron 2024-05-20 23:27:51 +02:00
parent a223cd34d8
commit 3ab8ba3466
No known key found for this signature in database
GPG key ID: 7998CB3EA6CE5CBC
8 changed files with 34 additions and 20 deletions

View file

@ -12,13 +12,10 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2 - uses: taiki-e/install-action@v2
with: with:
tool: selene,typos-cli tool: selene,typos-cli
- name: Run linters - name: Run linters
run: make lint run: make lint
@ -32,3 +29,13 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
version: latest version: latest
args: --color always --check lua/ tests/ args: --color always --check lua/ tests/
ruby_lint:
name: Rubocop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bundle exec rubocop

View file

@ -5,3 +5,13 @@ AllCops:
TargetRubyVersion: 3.3.1 TargetRubyVersion: 3.3.1
Style/StringLiterals: Style/StringLiterals:
EnforcedStyle: double_quotes EnforcedStyle: double_quotes
RSpec/DescribeClass:
Enabled: false
RSpec/MultipleExpectations:
Enabled: false
RSpec/ExampleLength:
Enabled: false
RSpec/NestedGroups:
Enabled: false
Style/NestedModifier:
Enabled: false

View file

@ -116,9 +116,7 @@ RSpec.describe "Branch Popup", :git, :nvim do
end end
describe "Create new branch" do describe "Create new branch" do
it "can create a new branch" do it "can create a new branch"
end
end end
describe "Create new spin-off" do describe "Create new spin-off" do
@ -150,6 +148,7 @@ RSpec.describe "Branch Popup", :git, :nvim do
end end
describe "pull request" do describe "pull request" do
it "can open a pull-request"
end end
end end
end end

View file

@ -29,7 +29,7 @@ RSpec.configure do |config|
config.include Helpers config.include Helpers
config.around(:each) do |example| config.around do |example|
with_remote = example.metadata.fetch(:with_remote_origin, false) with_remote = example.metadata.fetch(:with_remote_origin, false)
Dir.mktmpdir do |local| Dir.mktmpdir do |local|

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
RSpec.shared_context "git", :git do RSpec.shared_context "with git", :git do
let(:git) { Git.open(Dir.pwd) } let(:git) { Git.open(Dir.pwd) }
before do before do

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
RSpec.shared_context "nvim", :nvim do RSpec.shared_context "with nvim", :nvim do
let(:nvim) { NeovimClient.new } let(:nvim) { NeovimClient.new }
before { nvim.setup } before { nvim.setup }

View file

@ -3,12 +3,12 @@
return if ENV["CI"] return if ENV["CI"]
def dir_name(name) def dir_name(name)
name.match(/[^\/]+\/(?<dir_name>[^\.]+)/)[:dir_name] name.match(%r{[^/]+/(?<dir_name>[^\.]+)})[:dir_name]
end end
def ensure_installed(name) def ensure_installed(name)
tmp = File.join(PROJECT_DIR, "tmp") tmp = File.join(PROJECT_DIR, "tmp")
Dir.mkdir(tmp) if !Dir.exist?(tmp) FileUtils.mkdir_p(tmp)
dir = File.join(tmp, dir_name(name)) dir = File.join(tmp, dir_name(name))

View file

@ -5,7 +5,7 @@ class NeovimClient
@instance = nil @instance = nil
end end
def setup def setup # rubocop:disable Metrics/MethodLength
@instance = attach_child @instance = attach_child
# Sets up the runtimepath # Sets up the runtimepath
@ -30,7 +30,7 @@ class NeovimClient
@instance = nil @instance = nil
end end
def print_screen def print_screen # rubocop:disable Metrics/MethodLength
@instance.command("redraw") @instance.command("redraw")
screen = [] screen = []
@ -63,7 +63,7 @@ class NeovimClient
# Overload vim.fn.input() to prevent blocking. # Overload vim.fn.input() to prevent blocking.
def input(*args) def input(*args)
lua <<~LUA lua <<~LUA
local inputs = { #{args.map(&:inspect).join(",")} } local inputs = { #{args.map(&:inspect).join(',')} }
vim.fn.input = function() vim.fn.input = function()
return table.remove(inputs, 1) return table.remove(inputs, 1)
@ -71,16 +71,14 @@ class NeovimClient
LUA LUA
end end
def keys(keys) def keys(keys) # rubocop:disable Metrics/MethodLength
keys = keys.chars keys = keys.chars
while keys.length > 0 until keys.empty?
key = keys.shift key = keys.shift
if key == "<" key += keys.shift until key.last == ">" if key == "<"
key += keys.shift until key.last == ">"
end
if (written = @instance.input(key)).nil? if @instance.input(key).nil?
assert_alive! assert_alive!
raise "Failed to write key to neovim: #{key.inspect}" raise "Failed to write key to neovim: #{key.inspect}"
end end