Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CI

on:
push:
branches:
- master
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version:
- '2.7'
- '3.0'
- '3.1'
- '3.2'
- '3.3'
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Run tests
run: bundle exec rake spec
11 changes: 11 additions & 0 deletions .github/workflows/danger-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Danger Comment

on:
workflow_run:
workflows: [Danger]
types: [completed]

jobs:
comment:
uses: numbata/danger-pr-comment/.github/workflows/danger-comment.yml@v0.1.0
secrets: inherit
13 changes: 13 additions & 0 deletions .github/workflows/danger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Danger

on:
pull_request:
types: [opened, reopened, edited, synchronize]

jobs:
danger:
uses: numbata/danger-pr-comment/.github/workflows/danger-run.yml@v0.1.0
secrets: inherit
with:
ruby-version: '3.4'
bundler-cache: true
20 changes: 20 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Rubocop

on:
push:
branches:
- master
pull_request:

jobs:
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
- name: Run rubocop
run: bundle exec rubocop
11 changes: 8 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
AllCops:
NewCops: enable
Exclude:
- vendor/**/*

Metrics/BlockLength:
Enabled: fale
Enabled: false

Metrics/LineLength:
Enabled: fale
Layout/LineLength:
Enabled: false

Style/ModuleFunction:
Enabled: false
Expand All @@ -15,3 +16,7 @@ Style/FrozenStringLiteralComment:
Enabled: false

inherit_from: .rubocop_todo.yml

plugins:
- rubocop-rspec
- rubocop-rake
152 changes: 109 additions & 43 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,133 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-07-28 16:56:29 -0400 using RuboCop version 0.73.0.
# on 2026-01-02 20:08:28 UTC using RuboCop version 1.82.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: squiggly, active_support, powerpack, unindent
Layout/IndentHeredoc:
# Offense count: 1
Gemspec/RequiredRubyVersion:
Exclude:
- 'lib/toc/plugin.rb'
- 'spec/toc_spec.rb'
- 'danger-toc.gemspec'

# Offense count: 4
# Offense count: 2
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 19

# Offense count: 8
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 107
Max: 20

# Offense count: 3
# Configuration parameters: CountComments, ExcludedMethods.
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 21
Max: 20

# Offense count: 3
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
Naming/MethodParameterName:
Exclude:
- 'lib/toc/constructors/kramdown_constructor.rb'
- 'lib/toc/extractor.rb'

# Offense count: 1
# Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
# AllowedMethods: call
# WaywardPredicates: nonzero?
Naming/PredicateMethod:
Exclude:
- 'lib/toc/plugin.rb'

# Offense count: 2
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
# NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_
# NameWhitelist: is_a?
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
# NamePrefix: is_, has_, have_, does_
# ForbiddenPrefixes: is_, has_, have_, does_
# AllowedMethods: is_a?
# MethodDefinitionMacros: define_method, define_singleton_method
Naming/PredicateName:
Naming/PredicatePrefix:
Exclude:
- 'spec/**/*'
- 'lib/toc/markdown_file.rb'
- 'lib/toc/plugin.rb'

# Offense count: 8
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'spec/config_spec.rb'
- 'spec/toc_spec.rb'

# Offense count: 7
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
# SupportedStyles: described_class, explicit
RSpec/DescribedClass:
Exclude:
- 'spec/markdown_file/danger_toc_readme_spec.rb'
- 'spec/markdown_file/one_section_spec.rb'
- 'spec/markdown_file/one_section_with_toc_level_spec.rb'
- 'spec/markdown_file/one_section_with_toc_spec.rb'
- 'spec/markdown_file/with_quoted_example_spec.rb'
- 'spec/markdown_file/with_underscore_in_section_name_spec.rb'
- 'spec/toc_spec.rb'

# Offense count: 3
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at, ip, db
Naming/UncommunicativeMethodParamName:
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 10

# Offense count: 6
RSpec/MultipleExpectations:
Max: 4

# Offense count: 39
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Exclude:
- 'lib/toc/constructors/kramdown_constructor.rb'
- 'lib/toc/extractor.rb'
- 'spec/markdown_file/danger_toc_readme_spec.rb'
- 'spec/markdown_file/one_section_spec.rb'
- 'spec/markdown_file/one_section_with_toc_level_spec.rb'
- 'spec/markdown_file/one_section_with_toc_spec.rb'
- 'spec/markdown_file/with_quoted_example_spec.rb'
- 'spec/markdown_file/with_underscore_in_section_name_spec.rb'
- 'spec/toc_spec.rb'

# Offense count: 13
# Configuration parameters: AllowedGroups.
RSpec/NestedGroups:
Max: 5

# Offense count: 8
# This cop supports unsafe autocorrection (--autocorrect-all).
RSpec/ReceiveMessages:
Exclude:
- 'spec/toc_spec.rb'

# Offense count: 9
# Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector.
# SupportedInflectors: default, active_support
RSpec/SpecFilePathFormat:
Exclude:
- '**/spec/routing/**/*'
- 'spec/config_spec.rb'
- 'spec/constructors_spec.rb'
- 'spec/markdown_file/danger_toc_readme_spec.rb'
- 'spec/markdown_file/one_section_spec.rb'
- 'spec/markdown_file/one_section_with_toc_level_spec.rb'
- 'spec/markdown_file/one_section_with_toc_spec.rb'
- 'spec/markdown_file/with_quoted_example_spec.rb'
- 'spec/markdown_file/with_underscore_in_section_name_spec.rb'
- 'spec/toc_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Rake/Desc:
Exclude:
- 'Rakefile'

# Offense count: 8
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
Expand All @@ -63,20 +140,9 @@ Style/Documentation:
- 'lib/toc/markdown_file.rb'
- 'lib/toc/plugin.rb'

# Offense count: 3
Style/DoubleNegation:
Exclude:
- 'lib/toc/markdown_file.rb'

# Offense count: 2
# Configuration parameters: MinBodyLength.
Style/GuardClause:
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Style/StringConcatenation:
Exclude:
- 'lib/toc/markdown_file.rb'

# Offense count: 26
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 123
- 'spec/spec_helper.rb'
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

### 0.2.1 (Next)

* [#18](https://github.com/dblock/danger-toc/pull/18): Migrate to danger-pr-comment workflow - [@dblock](https://github.com/dblock).
* [#18](https://github.com/dblock/danger-toc/pull/18): Migrate from Travis CI to GitHub Actions - [@dblock](https://github.com/dblock).
* [#18](https://github.com/dblock/danger-toc/pull/18): Upgrade rubocop to 1.82.0 - [@dblock](https://github.com/dblock).
* Your contribution here.

### 0.2.0 (2019/07/28)
Expand Down
4 changes: 3 additions & 1 deletion Dangerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# danger.systems
# frozen_string_literal: true

danger.import_dangerfile(gem: 'danger-pr-comment')

changelog.check!
toc.check!
16 changes: 10 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ gemspec

group :development, :test do
gem 'bundler'
gem 'danger-changelog', '~> 0.6.0'
gem 'guard', '~> 2.14'
gem 'guard-rspec', '~> 4.7'
gem 'danger'
gem 'danger-changelog'
gem 'danger-pr-comment'
gem 'guard'
gem 'guard-rspec'
gem 'listen'
gem 'pry'
gem 'rake', '~> 10.0'
gem 'rspec', '~> 3.4'
gem 'rubocop', '0.73.0'
gem 'rake'
gem 'rspec'
gem 'rubocop', '1.82.0'
gem 'rubocop-rake'
gem 'rubocop-rspec'
gem 'yard'
end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
A plugin for [danger.systems](http://danger.systems) that makes sure your project’s `README.md` has a TOC.

[![Gem Version](https://badge.fury.io/rb/danger-toc.svg)](https://badge.fury.io/rb/danger-toc)
[![Build Status](https://travis-ci.org/dblock/danger-toc.svg?branch=master)](https://travis-ci.org/dblock/danger-toc)
[![CI](https://github.com/dblock/danger-toc/actions/workflows/ci.yml/badge.svg)](https://github.com/dblock/danger-toc/actions/workflows/ci.yml)

## Table of Contents

Expand Down
6 changes: 3 additions & 3 deletions danger-toc.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'toc/gem_version.rb'
require 'toc/gem_version'

Gem::Specification.new do |spec|
spec.name = 'danger-toc'
Expand All @@ -14,10 +14,10 @@ Gem::Specification.new do |spec|

spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']

spec.add_dependency 'activesupport'
spec.add_dependency 'danger-plugin-api', '~> 1.0'
spec.add_dependency 'kramdown'
spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
spec.metadata['rubygems_mfa_required'] = 'true'
end
2 changes: 1 addition & 1 deletion lib/toc/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Config
header
].freeze

ACCESSORS = ATTRIBUTES.map { |name| "#{name}=".to_sym }
ACCESSORS = ATTRIBUTES.map { |name| :"#{name}=" }

DELEGATORS = ATTRIBUTES + ACCESSORS

Expand Down
2 changes: 1 addition & 1 deletion lib/toc/constructors/kramdown_constructor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def flatten(el)
end

def convert(el)
toc = flatten(super(el))
toc = flatten(super)
has_toc = false
headers = []
toc.each do |line|
Expand Down
Loading