diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7b3eb46..1b0fe54 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,7 +4,21 @@ updates: directory: "/" schedule: interval: weekly + groups: + all-dependencies: + patterns: + - "*" + update-types: + - "minor" + - "patch" - package-ecosystem: github-actions directory: "/" schedule: interval: weekly + groups: + all-dependencies: + patterns: + - "*" + update-types: + - "minor" + - "patch" \ No newline at end of file diff --git a/.github/workflows/accessibility-alt-text-bot.yml b/.github/workflows/accessibility-alt-text-bot.yml index 0eac9eb..084a210 100644 --- a/.github/workflows/accessibility-alt-text-bot.yml +++ b/.github/workflows/accessibility-alt-text-bot.yml @@ -23,4 +23,4 @@ jobs: if: ${{ github.event.issue || github.event.pull_request || github.event.discussion }} steps: - name: Get action 'github/accessibility-alt-text-bot' - uses: github/accessibility-alt-text-bot@v1.4.0 + uses: github/accessibility-alt-text-bot@v1.7.1 diff --git a/.github/workflows/auto-approve-and-merge.yml b/.github/workflows/auto-approve-and-merge.yml index baa04d9..2c7fa07 100644 --- a/.github/workflows/auto-approve-and-merge.yml +++ b/.github/workflows/auto-approve-and-merge.yml @@ -11,7 +11,7 @@ jobs: if: ${{ github.actor == 'dependabot[bot]' }} steps: - name: Approve PR - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c21c19e..bc3b0e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,13 +2,17 @@ name: CI on: [push, pull_request] +permissions: + contents: write + pull-requests: write + jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Ruby - uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@a4effe49ee8ee5b8b5091268c473a4628afb5651 with: ruby-version: '3.0' bundler-cache: true @@ -17,17 +21,13 @@ jobs: bundle install bundle exec rubocop test: - strategy: - fail-fast: false - matrix: - ruby_version: ["2.7", "3.0"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Ruby - uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@a4effe49ee8ee5b8b5091268c473a4628afb5651 with: - ruby-version: ${{ matrix.ruby_version }} + ruby-version: '3.0' bundler-cache: true - name: Install dependencies run: bundle install @@ -38,7 +38,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Ruby - uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@a4effe49ee8ee5b8b5091268c473a4628afb5651 with: ruby-version: '3.0' bundler-cache: true @@ -51,7 +51,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Ruby - uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@a4effe49ee8ee5b8b5091268c473a4628afb5651 with: ruby-version: '3.0' bundler-cache: true diff --git a/Gemfile.lock b/Gemfile.lock index 2d4929d..8c8d4a7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,116 +1,137 @@ PATH remote: . specs: - erblint-github (0.5.1) + erblint-github (1.0.1) GEM remote: https://rubygems.org/ specs: - actionview (7.0.7.2) - activesupport (= 7.0.7.2) + actionview (7.1.5.1) + activesupport (= 7.1.5.1) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activesupport (7.0.7.2) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activesupport (7.1.5.1) + base64 + benchmark (>= 0.3) + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) + mutex_m + securerandom (>= 0.3) tzinfo (~> 2.0) - ast (2.4.2) - base64 (0.1.1) - better_html (2.0.2) + ast (2.4.3) + base64 (0.2.0) + benchmark (0.4.0) + better_html (2.1.1) actionview (>= 6.0) activesupport (>= 6.0) ast (~> 2.0) erubi (~> 1.4) parser (>= 2.4) smart_properties - builder (3.2.4) - concurrent-ruby (1.2.2) + bigdecimal (3.1.9) + builder (3.3.0) + concurrent-ruby (1.3.5) + connection_pool (2.5.0) crass (1.0.6) - erb_lint (0.5.0) + drb (2.2.1) + erb_lint (0.9.0) activesupport better_html (>= 2.0.1) parser (>= 2.7.1.4) rainbow - rubocop + rubocop (>= 1) smart_properties - erubi (1.12.0) - i18n (1.14.1) + erubi (1.13.1) + i18n (1.14.7) concurrent-ruby (~> 1.0) - json (2.6.3) - language_server-protocol (3.17.0.3) - loofah (2.21.3) + json (2.12.2) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + logger (1.6.6) + loofah (2.24.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) - mini_portile2 (2.8.4) - minitest (5.20.0) - mocha (2.1.0) + mini_portile2 (2.8.8) + minitest (5.25.5) + mocha (2.7.1) ruby2_keywords (>= 0.0.5) - nokogiri (1.15.4) + mutex_m (0.3.0) + nokogiri (1.17.2) mini_portile2 (~> 2.8.2) racc (~> 1.4) - parallel (1.23.0) - parser (3.2.2.4) + parallel (1.27.0) + parser (3.3.8.0) ast (~> 2.4.1) racc - racc (1.7.1) - rack (3.0.8) + prism (1.4.0) + racc (1.8.1) + rack (3.1.16) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) + rails-html-sanitizer (1.6.2) loofah (~> 2.21) - nokogiri (~> 1.14) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) rainbow (3.1.1) - rake (13.0.6) - regexp_parser (2.8.2) - rexml (3.2.6) - rubocop (1.57.1) - base64 (~> 0.1.1) + rake (13.3.0) + regexp_parser (2.10.0) + rubocop (1.78.0) json (~> 2.3) - language_server-protocol (>= 3.17.0) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) - parser (>= 3.2.2.4) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.1, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.45.1, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.29.0) - parser (>= 3.2.1.0) - rubocop-github (0.20.0) - rubocop (>= 1.37) - rubocop-performance (>= 1.15) - rubocop-rails (>= 2.17) - rubocop-performance (1.16.0) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) - rubocop-rails (2.17.4) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.45.1) + parser (>= 3.3.7.2) + prism (~> 1.4) + rubocop-github (0.23.0) + rubocop (>= 1.72) + rubocop-performance (>= 1.24) + rubocop-rails (>= 2.23) + rubocop-performance (1.24.0) + lint_roller (~> 1.1) + rubocop (>= 1.72.1, < 2.0) + rubocop-ast (>= 1.38.0, < 2.0) + rubocop-rails (2.30.3) activesupport (>= 4.2.0) + lint_roller (~> 1.1) rack (>= 1.1) - rubocop (>= 1.33.0, < 2.0) + rubocop (>= 1.72.1, < 2.0) + rubocop-ast (>= 1.38.0, < 2.0) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) + securerandom (0.3.2) smart_properties (1.17.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.5.0) + unicode-display_width (3.1.4) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) PLATFORMS ruby DEPENDENCIES - erb_lint (~> 0.5.0) + erb_lint (~> 0.9.0) erblint-github! - minitest (~> 5.20.0) - mocha (~> 2.1.0) - rake (~> 13.0.6) - rubocop (= 1.57.1) - rubocop-github (~> 0.20.0) + minitest (~> 5.25.1) + mocha (~> 2.7.0) + rake (~> 13.3.0) + rubocop (= 1.78.0) + rubocop-github (~> 0.23.0) BUNDLED WITH 2.3.26 diff --git a/README.md b/README.md index 785d11e..a8452df 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ inherit_gem: ## Testing -``` +```sh bundle install bundle exec rake ``` diff --git a/erblint-github.gemspec b/erblint-github.gemspec index ee3116f..4599235 100644 --- a/erblint-github.gemspec +++ b/erblint-github.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = "erblint-github" - s.version = "0.5.1" + s.version = "1.0.1" s.summary = "erblint GitHub" s.description = "Template style checking for GitHub Ruby repositories" s.homepage = "https://github.com/github/erblint-github" @@ -11,18 +11,18 @@ Gem::Specification.new do |s| s.files = Dir["README.md", "LICENSE", "lib/**/*", "config/**/*"] s.require_paths = ["lib"] - s.required_ruby_version = ">= 2.7.0" + s.required_ruby_version = ">= 3.0.0" s.email = ["opensource+erblint-github@github.com"] s.authors = ["GitHub Open Source"] - s.add_development_dependency "erb_lint", "~> 0.5.0" - s.add_development_dependency "minitest", "~> 5.20.0" - s.add_development_dependency "mocha", "~> 2.1.0" - s.add_development_dependency "rake", "~> 13.0.6" + s.add_development_dependency "erb_lint", "~> 0.9.0" + s.add_development_dependency "minitest", "~> 5.25.1" + s.add_development_dependency "mocha", "~> 2.7.0" + s.add_development_dependency "rake", "~> 13.3.0" - s.add_development_dependency "rubocop", "= 1.57.1" - s.add_development_dependency "rubocop-github", "~> 0.20.0" + s.add_development_dependency "rubocop", "= 1.78.0" + s.add_development_dependency "rubocop-github", "~> 0.23.0" s.metadata["rubygems_mfa_required"] = "true" s.executables << "erblint-disable" diff --git a/lib/erblint-github/linters/custom_helpers.rb b/lib/erblint-github/linters/custom_helpers.rb index d43eb4c..f1d791f 100644 --- a/lib/erblint-github/linters/custom_helpers.rb +++ b/lib/erblint-github/linters/custom_helpers.rb @@ -36,11 +36,12 @@ def counter_correct?(processed_source) processed_source.parser.ast.descendants(:erb).each do |node| indicator_node, _, code_node, = *node indicator = indicator_node&.loc&.source - comment = code_node&.loc&.source&.strip + comment = code_node&.loc&.source + stripped_comment = comment&.strip - if indicator == "#" && comment.start_with?("erblint:counter") && comment.match(rule_name) + if indicator == "#" && stripped_comment.start_with?("erblint:counter") && stripped_comment.match(rule_name) comment_node = node - expected_count = comment.match(/\s(\d+)\s?$/)[1].to_i + expected_count = stripped_comment.match(/\s(\d+)\s?$/)[1].to_i end end @@ -60,12 +61,6 @@ def counter_correct?(processed_source) end end - # Map possible values from condition - def basic_conditional_code_check(code) - conditional_match = code.match(/["'](.+)["']\sif|unless\s.+/) || code.match(/.+\s?\s["'](.+)["']\s:\s["'](.+)["']/) - [conditional_match[1], conditional_match[2]].compact if conditional_match - end - def tags(processed_source) processed_source.parser.nodes_with_type(:tag).map { |tag_node| BetterHtml::Tree::Tag.from_node(tag_node) } end