diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml new file mode 100644 index 0000000..b377951 --- /dev/null +++ b/.github/workflows/rubocop.yml @@ -0,0 +1,17 @@ +name: RuboCop + +on: + push: + branches: [main] + pull_request: + +jobs: + rubocop: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.1" + - run: gem install rubocop -v 1.82.1 + - run: rubocop diff --git a/.rubocop.yml b/.rubocop.yml index ad522f1..fcf6b9f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,7 @@ AllCops: NewCops: enable SuggestExtensions: false + TargetRubyVersion: 3.1 Style/Documentation: Enabled: false diff --git a/README.md b/README.md index 755e7f1..6989da1 100644 --- a/README.md +++ b/README.md @@ -133,3 +133,9 @@ Example: If a 96kHz file is synced to an Octatrack (which only supports 44.1kHz) ```bash rake test ``` + +### Running RuboCop + +```bash +bundle exec rubocop +``` diff --git a/test/wavesync/config_test.rb b/test/wavesync/config_test.rb index af46dd2..70c6997 100644 --- a/test/wavesync/config_test.rb +++ b/test/wavesync/config_test.rb @@ -39,7 +39,7 @@ class ConfigTest < Wavesync::TestCase end test 'raises ConfigError when YAML root is not a hash' do - error = assert_raises(ConfigError) { Config.new(['not', 'a', 'hash']) } + error = assert_raises(ConfigError) { Config.new(%w[not a hash]) } assert_match 'must contain a YAML mapping', error.message end @@ -56,19 +56,19 @@ class ConfigTest < Wavesync::TestCase end test 'raises ConfigError when library key is missing' do - data = VALID_CONFIG.reject { |k, _| k == 'library' } + data = VALID_CONFIG.except('library') error = assert_raises(ConfigError) { Config.new(data) } assert_match "Missing required config key: 'library'", error.message end test 'raises ConfigError when devices key is missing' do - data = VALID_CONFIG.reject { |k, _| k == 'devices' } + data = VALID_CONFIG.except('devices') error = assert_raises(ConfigError) { Config.new(data) } assert_match "Missing required config key: 'devices'", error.message end test 'raises ConfigError when library is not a string' do - data = VALID_CONFIG.merge('library' => ['not', 'a', 'string']) + data = VALID_CONFIG.merge('library' => %w[not a string]) error = assert_raises(ConfigError) { Config.new(data) } assert_match "'library' must be a string", error.message end diff --git a/wavesync.gemspec b/wavesync.gemspec index 3e1b087..8eecd1e 100644 --- a/wavesync.gemspec +++ b/wavesync.gemspec @@ -9,9 +9,10 @@ Gem::Specification.new do |spec| spec.authors = ['Andreas Zecher'] spec.homepage = 'https://github.com/pixelate/wavesync' spec.metadata['documentation_uri'] = 'https://github.com/pixelate/wavesync?tab=readme-ov-file#wavesync' - spec.license = 'MIT' + spec.metadata['rubygems_mfa_required'] = 'true' + spec.license = 'MIT' - spec.required_ruby_version = '>= 3.0' + spec.required_ruby_version = '>= 3.1' spec.files = Dir['lib/**/*.rb', 'bin/*', 'config/**/*', 'LICENSE', 'README.md'] spec.bindir = 'bin'