diff --git a/.github/auto-merge.yml b/.github/auto-merge.yml new file mode 100644 index 0000000..ca80427 --- /dev/null +++ b/.github/auto-merge.yml @@ -0,0 +1,11 @@ +- match: + dependency_type: all + update_type: security:minor # includes patch updates! + +- match: + dependency_type: development + update_type: semver:minor # includes patch updates! + +- match: + dependency_type: production + update_type: semver:patch diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b401914 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 + +updates: + - package-ecosystem: bundler + directory: "/" + schedule: + interval: daily + time: "03:00" + timezone: UTC + labels: + - dependencies + - ruby diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..378899e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,53 @@ +name: CI +on: + - push +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2 + bundler-cache: true + + - name: Run tests + env: + RAILS_ENV: test + CC_TEST_REPORTER_ID: true + run: bundle exec rspec --color --format RSpec::Github::Formatter --format progress --require spec_helper + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + if: ${{ success() || failure() }} + with: + token: ${{ secrets.CODECOV_TOKEN }} + + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2 + bundler-cache: true + + - name: Run rubocop + uses: reviewdog/action-rubocop@v2 + with: + filter_mode: nofilter + rubocop_version: gemfile + rubocop_extensions: rubocop-rspec:gemfile rubocop-performance:gemfile + rubocop_flags: --parallel + reporter: github-check + skip_install: true + use_bundler: true + fail_on_error: true diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml new file mode 100644 index 0000000..6121be9 --- /dev/null +++ b/.github/workflows/dependabot.yml @@ -0,0 +1,15 @@ +name: Dependabot Automerge Check +on: + - pull_request_target + +jobs: + auto-merge: + if: github.actor == 'dependabot[bot]' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Automerge dependabot dependencies + uses: ahmadnassri/action-dependabot-auto-merge@v2 + with: + github-token: ${{ secrets.OPENHPI_BOT_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 46d8be9..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Ruby - -on: - push: - branches: - - master - - pull_request: - -jobs: - build: - runs-on: ubuntu-latest - name: Ruby ${{ matrix.ruby }} - strategy: - matrix: - ruby: - - '3.2.0' - - steps: - - uses: actions/checkout@v3 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true - - name: Run the default task - run: bundle exec rake diff --git a/.gitignore b/.gitignore index f2f3a8c..31c95f2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,8 @@ /pkg/ /spec/reports/ /tmp/ - +/.idea/ +*.iml # rspec failure tracking .rspec_status - -.idea/ +.byebug_history diff --git a/.rspec b/.rspec index 34c5164..bd5e028 100644 --- a/.rspec +++ b/.rspec @@ -1,3 +1,3 @@ ---format documentation +--format progress --color --require spec_helper diff --git a/.rubocop.yml b/.rubocop.yml index 5d4e5a8..466bdfc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,17 +1,22 @@ -require: rubocop-rspec +require: + - rubocop-performance + - rubocop-rspec + +inherit_from: + - .rubocop/layout.yml + - .rubocop/lint.yml + - .rubocop/metrics.yml + - .rubocop/rspec.yml + - .rubocop/style.yml AllCops: TargetRubyVersion: 3.2 + UseCache: True NewCops: enable Exclude: - - bin/* - - vendor/**/* - -Layout/LineLength: - Max: 120 - -Layout/SpaceInsideHashLiteralBraces: - EnforcedStyle: no_space - -Style/Documentation: - Enabled: false + - 'bin/*' + - 'vendor/**/*' + # Ignore local files for faster processing + - 'tmp/**/*' + - 'out/**/*' + - 'coverage/**/*' diff --git a/.rubocop/layout.yml b/.rubocop/layout.yml new file mode 100644 index 0000000..77bda0d --- /dev/null +++ b/.rubocop/layout.yml @@ -0,0 +1,39 @@ +# layout cop settings + +Layout/ArgumentAlignment: + EnforcedStyle: with_fixed_indentation + +Layout/CaseIndentation: + EnforcedStyle: end + SupportedStyles: + - case + - end + IndentOneStep: true + +Layout/FirstArrayElementIndentation: + EnforcedStyle: consistent + +Layout/FirstHashElementIndentation: + EnforcedStyle: consistent + +# +# There are good reasons for key as well as table style. +# +Layout/HashAlignment: + Enabled: false + +Layout/LineLength: + Exclude: + - "spec/**/*" + Max: 140 + +Layout/MultilineMethodCallIndentation: + EnforcedStyle: indented + +Layout/SpaceInsideBlockBraces: + EnforcedStyle: space + EnforcedStyleForEmptyBraces: no_space + SpaceBeforeBlockParameters: false + +Layout/SpaceInsideHashLiteralBraces: + EnforcedStyle: no_space diff --git a/.rubocop/lint.yml b/.rubocop/lint.yml new file mode 100644 index 0000000..6a50611 --- /dev/null +++ b/.rubocop/lint.yml @@ -0,0 +1,13 @@ +# lint cop settings + +# +# False positives: +# * expect { something }.to change { something } often triggers this +# +Lint/AmbiguousBlockAssociation: + Exclude: + - "spec/**/*_spec.rb" + +Lint/EmptyBlock: + Exclude: + - 'spec/**/*' diff --git a/.rubocop/metrics.yml b/.rubocop/metrics.yml new file mode 100644 index 0000000..2c4ed47 --- /dev/null +++ b/.rubocop/metrics.yml @@ -0,0 +1,31 @@ +# metric cop settings + +Metrics/BlockLength: + Exclude: + # Common files with e.g. block based DSLs + - "spec/**/*" + - "**/*.rake" + - "Rakefile" + - "Guardfile" + - "**/*/Rakefile" + - 'dachsfisch.gemspec' + Max: 50 + +Metrics/ClassLength: + Max: 150 + +# +# Often used as a proxy for complexity in a method, but causes many false +# positives, e.g. when generating large, but simple, hashes. +# We want to rely on CyclomaticComplexity instead. +# +Metrics/MethodLength: + Enabled: true + Max: 20 + +# +# This seems to be the cop that is closest to what we're interested in, which +# is the kind of complexity that usually surfaces in deep nesting. +# +Metrics/CyclomaticComplexity: + Enabled: true diff --git a/.rubocop/rails.yml b/.rubocop/rails.yml new file mode 100644 index 0000000..2750b1d --- /dev/null +++ b/.rubocop/rails.yml @@ -0,0 +1,4 @@ +# rails cop settings + +Rails: + Enabled: true diff --git a/.rubocop/rspec.yml b/.rubocop/rspec.yml new file mode 100644 index 0000000..06d7dd6 --- /dev/null +++ b/.rubocop/rspec.yml @@ -0,0 +1,20 @@ +# rspec cop settings + +RSpec: + Include: + - "spec/**/*_spec.rb" + - "spec/spec_helper.rb" + - "spec/dachsfisch_spec.rb" + +# +# Too stupid. There are also views, templates, request specs etc. +# +RSpec/DescribeClass: + Exclude: + - "spec/custom_matchers/*" + +RSpec/MultipleMemoizedHelpers: + Enabled: false + +RSpec/NestedGroups: + Max: 5 diff --git a/.rubocop/style.yml b/.rubocop/style.yml new file mode 100644 index 0000000..5aed184 --- /dev/null +++ b/.rubocop/style.yml @@ -0,0 +1,74 @@ +# style cop settings + +# +# Nein. Period. Try to keep it English, but there *will* references using +# unicode characters. +# +Style/AsciiComments: + Enabled: false + +# +# Both styles or mixtures are reasonable +# +Style/ClassAndModuleChildren: + EnforcedStyle: compact + Enabled: false + +# +# Maybe a bit uncommon for new devs and often results in heavily indented code +# blocks. +# +Style/ConditionalAssignment: + Enabled: false + +# +# Would be better but unlikely... +# +Style/Documentation: + Enabled: false + +# +# Okay for conditions, but false positive in return statements (e.g. APIs) +# +Style/DoubleNegation: + Enabled: false + +# +# Our default string token has the '%{value}' format +# +Style/FormatStringToken: + EnforcedStyle: template + +# +# Far to often easy to read without. +# +Style/GuardClause: + Enabled: false + +# +# IfUnlessModifier has no own line length but we do not want it to force 120 +# chars long modifiers just because we allow a few long lines. +# +Style/IfUnlessModifier: + Enabled: false + +# +# Well, we do this. To often to disable them. Studid. +# +Style/MultilineBlockChain: + Enabled: false + +#Style/NumericPredicate: +# Enabled: false + +Style/RaiseArgs: + EnforcedStyle: compact + +Style/SignalException: + EnforcedStyle: only_raise + +Style/TrailingCommaInArrayLiteral: + EnforcedStyleForMultiline: comma + +Style/TrailingCommaInHashLiteral: + EnforcedStyleForMultiline: comma diff --git a/Gemfile b/Gemfile index 8adac45..a4373de 100644 --- a/Gemfile +++ b/Gemfile @@ -2,5 +2,5 @@ source 'https://rubygems.org' -# Specify your gem's dependencies in proforma.gemspec +# Specify your gem's dependencies in dachsfisch.gemspec gemspec diff --git a/Gemfile.lock b/Gemfile.lock index f7c2d33..22d4689 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,56 +8,71 @@ GEM specs: ast (2.4.2) diff-lcs (1.5.0) + docile (1.4.0) json (2.6.3) parallel (1.22.1) - parser (3.2.0.0) + parser (3.2.2.0) ast (~> 2.4.1) rainbow (3.1.1) rake (13.0.6) - regexp_parser (2.6.2) + regexp_parser (2.7.0) rexml (3.2.5) rspec (3.12.0) rspec-core (~> 3.12.0) rspec-expectations (~> 3.12.0) rspec-mocks (~> 3.12.0) - rspec-core (3.12.0) + rspec-core (3.12.1) rspec-support (~> 3.12.0) rspec-expectations (3.12.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) - rspec-mocks (3.12.3) + rspec-github (2.4.0) + rspec-core (~> 3.0) + rspec-mocks (3.12.5) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) rspec-support (3.12.0) - rubocop (1.44.1) + rubocop (1.49.0) json (~> 2.3) parallel (~> 1.10) parser (>= 3.2.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.24.1, < 2.0) + rubocop-ast (>= 1.28.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.24.1) - parser (>= 3.1.1.0) + rubocop-ast (1.28.0) + parser (>= 3.2.1.0) rubocop-capybara (2.17.1) rubocop (~> 1.41) - rubocop-rspec (2.18.1) + rubocop-performance (1.16.0) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + rubocop-rspec (2.19.0) rubocop (~> 1.33) rubocop-capybara (~> 2.17) - ruby-progressbar (1.11.0) + ruby-progressbar (1.13.0) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) unicode-display_width (2.4.2) PLATFORMS - x86_64-linux + ruby DEPENDENCIES dachsfisch! rake (~> 13.0) rspec (~> 3.0) - rubocop (~> 1.21) - rubocop-rspec (~> 2.18.1) + rspec-github (~> 2.4.0) + rubocop (~> 1.49.0) + rubocop-performance (~> 1.16.0) + rubocop-rspec (~> 2.19.0) + simplecov (~> 0.22.0) BUNDLED WITH - 2.4.3 + 2.4.10 diff --git a/Rakefile b/Rakefile index 4964751..05fde3d 100644 --- a/Rakefile +++ b/Rakefile @@ -2,11 +2,10 @@ require 'bundler/gem_tasks' require 'rspec/core/rake_task' +require 'rubocop/rake_task' RSpec::Core::RakeTask.new(:spec) -require 'rubocop/rake_task' - RuboCop::RakeTask.new task default: %i[spec rubocop] diff --git a/dachsfisch.gemspec b/dachsfisch.gemspec index 6228089..ba44e07 100644 --- a/dachsfisch.gemspec +++ b/dachsfisch.gemspec @@ -12,7 +12,7 @@ Gem::Specification.new do |spec| spec.description = 'Implements a bidirectional converter for XML and JSON based on the badgerfish-specification' spec.homepage = 'https://github.com/openHPI/dachsfisch' spec.license = 'MIT' - spec.required_ruby_version = '>= 3.2.0' + spec.required_ruby_version = '>= 3.2' # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'" @@ -27,13 +27,18 @@ Gem::Specification.new do |spec| (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)}) end end + spec.bindir = 'exe' - spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } + spec.executables = spec.files.grep(%r{\Aexe/}) {|f| File.basename(f) } spec.require_paths = ['lib'] spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec', '~> 3.0' - spec.add_development_dependency 'rubocop', '~> 1.21' - spec.add_development_dependency 'rubocop-rspec', '~> 2.18.1' + spec.add_development_dependency 'rspec-github', '~> 2.4.0' + spec.add_development_dependency 'rubocop', '~> 1.49.0' + spec.add_development_dependency 'rubocop-performance', '~> 1.16.0' + spec.add_development_dependency 'rubocop-rspec', '~> 2.19.0' + spec.add_development_dependency 'simplecov', '~> 0.22.0' + spec.metadata['rubygems_mfa_required'] = 'true' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0337692..1d078f4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,8 @@ # frozen_string_literal: true +require 'simplecov' +SimpleCov.start + require 'dachsfisch' RSpec.configure do |config|