rubocop-md 0.2.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 79797f2e2130aabc8bac1cc72ecefe5acdb367d2
4
- data.tar.gz: 4094bca4c4e9be29fa8b6630415e70c23a562838
2
+ SHA256:
3
+ metadata.gz: 4e0bc7a246c9b83d118a61ec06d5a5142c5444d89143db2b5782eeaad048d1fb
4
+ data.tar.gz: 5fa52e9b357b75c79cffbf8d4ed1d8d7fa5e19435082e70f38e1bbd02fd0d80c
5
5
  SHA512:
6
- metadata.gz: 60508616bb720460e5f6653aa0fa4ce852ad790858c32a52091e146d182d77cb6ac7d6a3ff0980c0917364aa21c8636e3d4529f0722ab161b821e9cc19320769
7
- data.tar.gz: aa8cb2cdfd4416790d977f84a53feb031d551f2111ec701b3759a0fcb4ddc2fe8e1806685be0565b437b9ff08c48e282e2e418088d398087319f807f90d04873
6
+ metadata.gz: c29861c629e268aab54631f72d72971b6991d4b8413d65083d68b5726e321aabd6ee45a29e594b18efc37d10ece6a4d1c8ebf9927ef8a0fee9c291c7d841939d
7
+ data.tar.gz: 717e225fce45263a727732a4b7e17b3e98fde179b82bfe259631657767f6dc7210fb22e7885fab51d6502bdf446403fc9b65c473fb16b3075791503e710be08c
@@ -1,4 +1,5 @@
1
1
  AllCops:
2
+ NewCops: enable
2
3
  Include:
3
4
  - 'lib/**/*.rb'
4
5
  - 'lib/**/*.rake'
@@ -12,10 +13,7 @@ AllCops:
12
13
  - '*.gemspec'
13
14
  DisplayCopNames: true
14
15
  StyleGuideCopsOnly: false
15
- TargetRubyVersion: 2.2
16
-
17
- Rails:
18
- Enabled: false
16
+ TargetRubyVersion: 2.4
19
17
 
20
18
  Style/Documentation:
21
19
  Exclude:
@@ -31,13 +29,26 @@ Style/ClassAndModuleChildren:
31
29
  Exclude:
32
30
  - 'test/**/*.rb'
33
31
 
32
+ Style/HashEachMethods:
33
+ Enabled: true
34
+
35
+ Style/HashTransformKeys:
36
+ Enabled: true
37
+
38
+ Style/HashTransformValues:
39
+ Enabled: true
40
+
34
41
  Layout/EmptyLinesAroundArguments:
35
42
  Enabled: false
36
43
 
37
44
  Layout/SpaceInsideStringInterpolation:
38
45
  EnforcedStyle: no_space
39
46
 
40
- Metrics/LineLength:
47
+ Naming/FileName:
48
+ Exclude:
49
+ - 'lib/rubocop-md.rb'
50
+
51
+ Layout/LineLength:
41
52
  Max: 100
42
53
  Exclude:
43
54
  - 'test/**/*.rb'
@@ -1,28 +1,33 @@
1
1
  sudo: false
2
2
  language: ruby
3
- before_install: gem install bundler -v 1.15.4
3
+ before_install:
4
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
5
+ - gem install bundler -v '< 2'
6
+
7
+ notifications:
8
+ email: false
4
9
 
5
10
  matrix:
6
11
  fast_finish: true
7
12
  include:
8
13
  - rvm: ruby-head
9
14
  gemfile: gemfiles/rubocopmaster.gemfile
10
- - rvm: jruby-9.1.0.0
15
+ - rvm: jruby-9.2.8.0
11
16
  gemfile: Gemfile
12
- - rvm: 2.5.0
17
+ - rvm: 2.7
13
18
  gemfile: gemfiles/rubocopmaster.gemfile
14
- - rvm: 2.5.0
19
+ - rvm: 2.7
15
20
  gemfile: Gemfile
16
- - rvm: 2.4.2
21
+ - rvm: 2.6
17
22
  gemfile: Gemfile
18
- - rvm: 2.3.1
23
+ - rvm: 2.5
19
24
  gemfile: Gemfile
20
- - rvm: 2.2.0
25
+ - rvm: 2.4.2
21
26
  gemfile: Gemfile
22
27
  allow_failures:
23
28
  - rvm: ruby-head
24
29
  gemfile: gemfiles/rubocopmaster.gemfile
25
- - rvm: jruby-9.1.0.0
30
+ - rvm: jruby-9.2.8.0
26
31
  gemfile: Gemfile
27
32
  - rvm: 2.5.0
28
33
  gemfile: gemfiles/rubocopmaster.gemfile
@@ -0,0 +1,29 @@
1
+ # Change log
2
+
3
+ ## master (unreleased)
4
+
5
+ ## 0.4.1 (2020-11-05)
6
+
7
+ - Relax required RuboCop version.
8
+
9
+ ## 0.4.0 (2020-07-03)
10
+
11
+ - [#10](https://github.com/rubocop-hq/rubocop-md/pull/10): **Drop Ruby 2.3 support** ([@dominicsayers][])
12
+
13
+ ## 0.3.2 (2020-03-18)
14
+
15
+ - [#9](https://github.com/rubocop-hq/rubocop-md/pull/9): Add file extensions for Markdown ([@ybiquitous][])
16
+
17
+ ## 0.3.1 (2019-12-25)
18
+
19
+ - Upgrade to RuboCop 0.78 ([@palkan][])
20
+
21
+ Change the default config to use the new cop names for (e.g., `Layout/LineLength`).
22
+
23
+ ## 0.3.0 (2019-05-14)
24
+
25
+ - **Drop Ruby 2.2 support** ([@palkan][])
26
+
27
+ [@palkan]: https://github.com/palkan
28
+ [@ybiquitous]: https://github.com/ybiquitous
29
+ [@dominicsayers]: https://github.com/dominicsayers
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017 Vladimir Dementyev
3
+ Copyright (c) 2017-2019 Vladimir Dementyev
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/rubocop-md.svg)](http://badge.fury.io/rb/rubocop-md)
2
- [![Travis Status](https://travis-ci.org/palkan/rubocop-md.svg?branch=master)](https://travis-ci.org/palkan/rubocop-md)
2
+ [![Travis Status](https://travis-ci.org/rubocop-hq/rubocop-md.svg?branch=master)](https://travis-ci.org/rubocop-hq/rubocop-md)
3
3
 
4
4
  # Rubocop Markdown
5
5
 
@@ -12,7 +12,7 @@ Run Rubocop against your Markdown files to make sure that code examples follow s
12
12
  - Preserves specified language (i.e., do not try to analyze "\`\`\`sh")
13
13
  - **Supports autocorrect 📝**
14
14
 
15
- This project was developed to keep [test-prof](https://github.com/palkan/test-prof) guides consistent with Ruby style guide.
15
+ This project was developed to keep [test-prof](https://github.com/test-prof/test-prof) guides consistent with Ruby style guide.
16
16
 
17
17
  ## Installation
18
18
 
@@ -24,7 +24,7 @@ gem 'rubocop-md'
24
24
 
25
25
  And then execute:
26
26
 
27
- $ bundle
27
+ $ bundle install
28
28
 
29
29
  Or install it yourself as:
30
30
 
@@ -60,7 +60,7 @@ At first, add `rubocop-md` to your main `.rubocop.yml`:
60
60
  # .rubocop.yml
61
61
 
62
62
  require:
63
- - "rubocop-md"
63
+ - "rubocop-md"
64
64
  ```
65
65
 
66
66
  *Notice: additional options*
@@ -107,6 +107,28 @@ Lint/Void:
107
107
  - '*.md'
108
108
  ```
109
109
 
110
+ ### But if I want to use inline disabling some directive like in classic RuboCop?
111
+
112
+ You can use this tricks
113
+
114
+ ```
115
+ # my_post.md
116
+
117
+ ... some markdown ...
118
+
119
+ <span style="display:none;"># rubocop:disable all</span>
120
+
121
+ ```ruby
122
+ def my_poor_method(foo)
123
+ [:a, :b, :c] + ["#{foo}".to_sym]
124
+ end
125
+ ``` end of snippet
126
+
127
+ <span style="display:none;"># rubocop:enable all</span>
128
+
129
+ ... continuation of article ...
130
+ ```
131
+
110
132
  ## How it works?
111
133
 
112
134
  - Preprocess Markdown source into Ruby source preserving line numbers
@@ -129,7 +151,7 @@ To install this gem onto your local machine, run `bundle exec rake install`.
129
151
 
130
152
  ## Contributing
131
153
 
132
- Bug reports and pull requests are welcome on GitHub at https://github.com/palkan/rubocop-md.
154
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rubocop-hq/rubocop-md.
133
155
 
134
156
  ## License
135
157
 
@@ -17,6 +17,16 @@ Layout/TrailingBlankLines:
17
17
  - '**/*.md'
18
18
  - '**/*.markdown'
19
19
 
20
+ Layout/TrailingEmptyLines:
21
+ Exclude:
22
+ - '**/*.md'
23
+ - '**/*.markdown'
24
+
25
+ Lint/UselessAssignment:
26
+ Exclude:
27
+ - '**/*.md'
28
+ - '**/*.markdown'
29
+
20
30
  Naming/FileName:
21
31
  Exclude:
22
32
  - '**/*.md'
@@ -42,6 +52,6 @@ Style/FrozenStringLiteralComment:
42
52
  - '**/*.md'
43
53
  - '**/*.markdown'
44
54
 
45
- Metrics/LineLength:
55
+ Layout/LineLength:
46
56
  IgnoredPatterns:
47
57
  - !ruby/regexp /^\#/
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rubocop/markdown"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rubocop/markdown/version"
2
4
  require "pathname"
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "ripper"
2
4
 
3
5
  module RuboCop
@@ -10,9 +12,9 @@ module RuboCop
10
12
  # Only recognizes backticks-style code blocks.
11
13
  #
12
14
  # Try it: http://rubular.com/r/iJaKBkSrrT
13
- MD_REGEXP = /^([ \t]*`{3,4})([\w[[:blank:]]]*\n)([\s\S]+?)(^[ \t]*\1[[:blank:]]*\n?)/m
15
+ MD_REGEXP = /^([ \t]*`{3,4})([\w[[:blank:]]]*\n)([\s\S]+?)(^[ \t]*\1[[:blank:]]*\n?)/m.freeze
14
16
 
15
- MARKER = "<--rubocop/md-->".freeze
17
+ MARKER = "<--rubocop/md-->"
16
18
 
17
19
  # See https://github.com/github/linguist/blob/v5.3.3/lib/linguist/languages.yml#L3925
18
20
  RUBY_TYPES = %w[
@@ -71,8 +73,8 @@ module RuboCop
71
73
  walker = Walker.new
72
74
 
73
75
  parts.each do |part|
74
- if walker.code_body?
75
- next walker.next! if maybe_ruby?(@syntax) && valid_syntax?(@syntax, part)
76
+ if walker.code_body? && maybe_ruby?(@syntax) && valid_syntax?(@syntax, part)
77
+ next walker.next!
76
78
  end
77
79
 
78
80
  if walker.code_attr?
@@ -107,22 +109,24 @@ module RuboCop
107
109
  # Return true if it's explicit Ruby and warn_invalid?
108
110
  def valid_syntax?(syntax, src)
109
111
  return true if ruby?(syntax) && warn_invalid?
112
+
110
113
  !Ripper.sexp(src).nil?
111
114
  end
112
115
 
113
116
  # Whether to show warning when snippet is not a valid Ruby
114
117
  def warn_invalid?
115
- config["Markdown"] && config["Markdown"].fetch("WarnInvalid", true)
118
+ config["Markdown"]&.fetch("WarnInvalid", true)
116
119
  end
117
120
 
118
121
  # Whether to try to detect Ruby by parsing codeblock.
119
122
  # If it's set to false we lint only implicitly specified Ruby blocks.
120
123
  def autodetect?
121
- config["Markdown"] && config["Markdown"].fetch("Autodetect", true)
124
+ config["Markdown"]&.fetch("Autodetect", true)
122
125
  end
123
126
 
124
127
  def comment_lines!(src)
125
128
  return if src =~ /\A\n\z/
129
+
126
130
  src.gsub!(/^(.)/m, "##{MARKER}\\1")
127
131
  end
128
132
  end
@@ -1,9 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RuboCop
2
4
  module Markdown # :nodoc:
3
- MARKDOWN_EXTENSIONS = %w[.md .markdown].freeze
5
+ # According to Linguist.
6
+ # See https://github.com/github/linguist/blob/96ca71ab99c2f9928d5d69f4c08fd2a51440d045/lib/linguist/languages.yml#L3065-L3083
7
+ MARKDOWN_EXTENSIONS = %w[
8
+ .md
9
+ .markdown
10
+ .mdown
11
+ .mdwn
12
+ .mdx
13
+ .mkd
14
+ .mkdn
15
+ .mkdown
16
+ .ronn
17
+ .workbook
18
+ ].freeze
4
19
 
5
20
  class << self
6
21
  attr_accessor :config_store
22
+
7
23
  # Merge markdown config into default configuration
8
24
  # See https://github.com/backus/rubocop-rspec/blob/master/lib/rubocop/rspec/inject.rb
9
25
  def inject!
@@ -35,6 +51,7 @@ RuboCop::Runner.prepend(Module.new do
35
51
  # NOTE: we should involve preprocessing in RuboCop::CachedData#deserialize_offenses
36
52
  def file_offense_cache(file)
37
53
  return yield if RuboCop::Markdown.markdown_file?(file)
54
+
38
55
  super
39
56
  end
40
57
 
@@ -61,7 +78,7 @@ RuboCop::ProcessedSource.prepend(Module.new do
61
78
  def parse(src, *args)
62
79
  # only process Markdown files
63
80
  src = RuboCop::Markdown::Preprocess.new(path).call(src) if
64
- path.nil? || RuboCop::Markdown.markdown_file?(path)
81
+ path && RuboCop::Markdown.markdown_file?(path)
65
82
  super(src, *args)
66
83
  end
67
84
  end)
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RuboCop
2
4
  module Markdown
3
- VERSION = "0.2.0".freeze
5
+ VERSION = "0.4.1"
4
6
  end
5
7
  end
@@ -17,11 +17,21 @@ Gem::Specification.new do |spec|
17
17
  f.match(%r{^(test|spec|features)/})
18
18
  end
19
19
 
20
+ spec.metadata = {
21
+ "bug_tracker_uri" => "http://github.com/rubocop-hq/rubocop-md/issues",
22
+ "changelog_uri" => "https://github.com/rubocop-hq/rubocop-md/blob/master/CHANGELOG.md",
23
+ "documentation_uri" => "https://github.com/rubocop-hq/rubocop-md/blob/master/README.md",
24
+ "homepage_uri" => "https://github.com/rubocop-hq/rubocop-md",
25
+ "source_code_uri" => "http://github.com/rubocop-hq/rubocop-md"
26
+ }
27
+
28
+ spec.required_ruby_version = ">= 2.4.0"
29
+
20
30
  spec.require_paths = ["lib"]
21
31
 
22
- spec.add_runtime_dependency "rubocop", "~> 0.50"
32
+ spec.add_runtime_dependency "rubocop", ">= 0.60"
23
33
 
24
- spec.add_development_dependency "bundler", "~> 1.15"
25
- spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "bundler", ">= 1.15"
35
+ spec.add_development_dependency "rake", "~> 13.0"
26
36
  spec.add_development_dependency "minitest", "~> 5.0"
27
37
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-md
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-16 00:00:00.000000000 Z
11
+ date: 2020-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.50'
19
+ version: '0.60'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0.50'
26
+ version: '0.60'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.15'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.15'
41
41
  - !ruby/object:Gem::Dependency
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -78,6 +78,7 @@ files:
78
78
  - ".gitignore"
79
79
  - ".rubocop.yml"
80
80
  - ".travis.yml"
81
+ - CHANGELOG.md
81
82
  - Gemfile
82
83
  - LICENSE.txt
83
84
  - README.md
@@ -94,7 +95,12 @@ files:
94
95
  homepage: https://github.com/palkan/rubocop-md
95
96
  licenses:
96
97
  - MIT
97
- metadata: {}
98
+ metadata:
99
+ bug_tracker_uri: http://github.com/rubocop-hq/rubocop-md/issues
100
+ changelog_uri: https://github.com/rubocop-hq/rubocop-md/blob/master/CHANGELOG.md
101
+ documentation_uri: https://github.com/rubocop-hq/rubocop-md/blob/master/README.md
102
+ homepage_uri: https://github.com/rubocop-hq/rubocop-md
103
+ source_code_uri: http://github.com/rubocop-hq/rubocop-md
98
104
  post_install_message:
99
105
  rdoc_options: []
100
106
  require_paths:
@@ -103,15 +109,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
109
  requirements:
104
110
  - - ">="
105
111
  - !ruby/object:Gem::Version
106
- version: '0'
112
+ version: 2.4.0
107
113
  required_rubygems_version: !ruby/object:Gem::Requirement
108
114
  requirements:
109
115
  - - ">="
110
116
  - !ruby/object:Gem::Version
111
117
  version: '0'
112
118
  requirements: []
113
- rubyforge_project:
114
- rubygems_version: 2.6.13
119
+ rubygems_version: 3.0.6
115
120
  signing_key:
116
121
  specification_version: 4
117
122
  summary: Run Rubocop against your Markdown files to make sure that code examples follow