rubocop-md 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +5 -1
- data/.travis.yml +3 -3
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +1 -1
- data/README.md +25 -3
- data/config/default.yml +5 -0
- data/lib/rubocop-md.rb +2 -0
- data/lib/rubocop/markdown.rb +2 -0
- data/lib/rubocop/markdown/preprocess.rb +8 -4
- data/lib/rubocop/markdown/rubocop_ext.rb +3 -0
- data/lib/rubocop/markdown/version.rb +3 -1
- data/rubocop-md.gemspec +12 -2
- metadata +15 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 914629c131d136ea85643a2121decc4bfebb5213a6f5390a16c5fd6273ae632c
|
4
|
+
data.tar.gz: 8b8bf3581a9b1217b1a8aa843d6719c0425c6555e1686036a3b6f2fd2c118e46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5feb50478f1924e6bd518505b88d196575eeeaf842cbecd653fd7dd3e2baaf35dcd2300b3489d826f970828440944f7e4b27c6225c62080081c08ab73b8568b9
|
7
|
+
data.tar.gz: fee4f59f4ac8ff91a48f2de1f324ca3c4ac5d7041bfa54b3f61c1d2cadd7cfba9c22895146d68d9c11b84e0951500899a76a36b24e0bbe974f8969352e4264cf
|
data/.rubocop.yml
CHANGED
@@ -12,7 +12,7 @@ AllCops:
|
|
12
12
|
- '*.gemspec'
|
13
13
|
DisplayCopNames: true
|
14
14
|
StyleGuideCopsOnly: false
|
15
|
-
TargetRubyVersion: 2.
|
15
|
+
TargetRubyVersion: 2.3
|
16
16
|
|
17
17
|
Rails:
|
18
18
|
Enabled: false
|
@@ -37,6 +37,10 @@ Layout/EmptyLinesAroundArguments:
|
|
37
37
|
Layout/SpaceInsideStringInterpolation:
|
38
38
|
EnforcedStyle: no_space
|
39
39
|
|
40
|
+
Naming/FileName:
|
41
|
+
Exclude:
|
42
|
+
- 'lib/rubocop-md.rb'
|
43
|
+
|
40
44
|
Metrics/LineLength:
|
41
45
|
Max: 100
|
42
46
|
Exclude:
|
data/.travis.yml
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
|
-
before_install:
|
3
|
+
before_install:
|
4
|
+
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
5
|
+
- gem install bundler -v '< 2'
|
4
6
|
|
5
7
|
matrix:
|
6
8
|
fast_finish: true
|
@@ -17,8 +19,6 @@ matrix:
|
|
17
19
|
gemfile: Gemfile
|
18
20
|
- rvm: 2.3.1
|
19
21
|
gemfile: Gemfile
|
20
|
-
- rvm: 2.2.0
|
21
|
-
gemfile: Gemfile
|
22
22
|
allow_failures:
|
23
23
|
- rvm: ruby-head
|
24
24
|
gemfile: gemfiles/rubocopmaster.gemfile
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
CHANGED
@@ -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/
|
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
|
|
@@ -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
|
-
|
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
|
data/config/default.yml
CHANGED
data/lib/rubocop-md.rb
CHANGED
data/lib/rubocop/markdown.rb
CHANGED
@@ -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-->"
|
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[
|
@@ -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"]
|
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"]
|
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,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RuboCop
|
2
4
|
module Markdown # :nodoc:
|
3
5
|
MARKDOWN_EXTENSIONS = %w[.md .markdown].freeze
|
@@ -35,6 +37,7 @@ RuboCop::Runner.prepend(Module.new do
|
|
35
37
|
# NOTE: we should involve preprocessing in RuboCop::CachedData#deserialize_offenses
|
36
38
|
def file_offense_cache(file)
|
37
39
|
return yield if RuboCop::Markdown.markdown_file?(file)
|
40
|
+
|
38
41
|
super
|
39
42
|
end
|
40
43
|
|
data/rubocop-md.gemspec
CHANGED
@@ -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.3.0"
|
29
|
+
|
20
30
|
spec.require_paths = ["lib"]
|
21
31
|
|
22
|
-
spec.add_runtime_dependency "rubocop", "~> 0.
|
32
|
+
spec.add_runtime_dependency "rubocop", "~> 0.60"
|
23
33
|
|
24
|
-
spec.add_development_dependency "bundler", "
|
34
|
+
spec.add_development_dependency "bundler", ">= 1.15"
|
25
35
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
36
|
spec.add_development_dependency "minitest", "~> 5.0"
|
27
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-md
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,26 +16,26 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
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.
|
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
|
@@ -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:
|
112
|
+
version: 2.3.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
|
-
|
114
|
-
rubygems_version: 2.6.13
|
119
|
+
rubygems_version: 3.0.3
|
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
|