rubomatic-html 1.0.0 → 1.1.0.pre.rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/exe/rubomatic-html +1 -1
- data/lib/rubomatic/html/cop/base.rb +42 -0
- data/lib/rubomatic/html/cop/layout/base.rb +19 -0
- data/lib/rubomatic/html/cop/layout/line_length.rb +26 -0
- data/lib/rubomatic/html/cop/layout/multiple_line_breaks.rb +40 -0
- data/lib/rubomatic/html/cop/layout/trailing_whitespace.rb +26 -0
- data/lib/rubomatic/html/cop/style/base.rb +19 -0
- data/lib/rubomatic/html/cop/style/partial_instance_variable.rb +28 -0
- data/lib/rubomatic/html/version.rb +7 -0
- data/lib/rubomatic/html.rb +115 -0
- data/lib/rubomatic-html.rb +1 -111
- metadata +14 -13
- data/lib/rubomatic-html/cop/base.rb +0 -40
- data/lib/rubomatic-html/cop/layout/base.rb +0 -17
- data/lib/rubomatic-html/cop/layout/line_length.rb +0 -24
- data/lib/rubomatic-html/cop/layout/multiple_line_breaks.rb +0 -38
- data/lib/rubomatic-html/cop/layout/trailing_whitespace.rb +0 -24
- data/lib/rubomatic-html/cop/style/base.rb +0 -17
- data/lib/rubomatic-html/cop/style/partial_instance_variable.rb +0 -26
- data/lib/rubomatic-html/version.rb +0 -5
- /data/lib/{rubomatic-html → rubomatic/html}/cop/cops.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af8a926ac9a2795a08cc7133d7ba56f142a9b8837b715a7ca4dd116a922badef
|
4
|
+
data.tar.gz: 549c3fd88fa42d3837577184a4d0082982a9794d546b53235861b1b3439d2121
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 258d8f157a8fe32214ba59336493805f2a769e11d134c6e088f9cfbd49ba0c3a2cd423190c8cf9aab8269a00296dad68a2ad2a33cc98c0c3ca5e69d2bc0c9694
|
7
|
+
data.tar.gz: 123d9d909d5425bb748ddc310e68373e3ce6d7bfcc8bd3e1125a9d1e03df66fae95d7bc611e774b2933d5acc76270f52829ede9c88770f6cda79d4b6738dee11
|
data/exe/rubomatic-html
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rubomatic
|
4
|
+
module Html
|
5
|
+
module Cop
|
6
|
+
class Base
|
7
|
+
# @return [String]
|
8
|
+
attr_accessor :file
|
9
|
+
|
10
|
+
# Name for cop
|
11
|
+
#
|
12
|
+
# @return [String]
|
13
|
+
#
|
14
|
+
def self.name
|
15
|
+
'Base'
|
16
|
+
end
|
17
|
+
|
18
|
+
# :nodoc:
|
19
|
+
def initialize(file)
|
20
|
+
@file = file
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# Outputs filename:line_number locations of HTML files that trigger the cop
|
26
|
+
#
|
27
|
+
# @param _line [String] the line in the html
|
28
|
+
# @param _index [Integer] the 1-index of the line
|
29
|
+
#
|
30
|
+
# @return [void]
|
31
|
+
#
|
32
|
+
def run_for_line(_line, _index)
|
33
|
+
error_message = <<~TEXT
|
34
|
+
Warning: Method `run_for_line` needs overridden! Some cops may not display failing messages.
|
35
|
+
TEXT
|
36
|
+
|
37
|
+
puts("\e[33m#{error_message}\e[0m")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rubomatic
|
4
|
+
module Html
|
5
|
+
module Cop
|
6
|
+
module Layout
|
7
|
+
class Base < Rubomatic::Html::Cop::Base
|
8
|
+
# Department for cop
|
9
|
+
#
|
10
|
+
# @return [String]
|
11
|
+
#
|
12
|
+
def self.department
|
13
|
+
'Layout'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rubomatic
|
4
|
+
module Html
|
5
|
+
module Cop
|
6
|
+
module Layout
|
7
|
+
class LineLength < Rubomatic::Html::Cop::Layout::Base
|
8
|
+
# Name for the cop
|
9
|
+
#
|
10
|
+
# @return [String]
|
11
|
+
#
|
12
|
+
def self.name
|
13
|
+
[department, 'LineLength'].join('/')
|
14
|
+
end
|
15
|
+
|
16
|
+
# @see super
|
17
|
+
def run_for_line(line, index)
|
18
|
+
return if line.size <= 120
|
19
|
+
|
20
|
+
puts("#{file}:#{index}: is over 120 characters")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rubomatic
|
4
|
+
module Html
|
5
|
+
module Cop
|
6
|
+
module Layout
|
7
|
+
class MultipleLineBreaks < Rubomatic::Html::Cop::Layout::Base
|
8
|
+
# @return [Boolean] tracks multiple consecutive line breaks
|
9
|
+
attr_accessor :prev_break
|
10
|
+
|
11
|
+
# Name for the cop
|
12
|
+
#
|
13
|
+
# @return [String]
|
14
|
+
#
|
15
|
+
def self.name
|
16
|
+
[department, 'MultipleLineBreaks'].join('/')
|
17
|
+
end
|
18
|
+
|
19
|
+
# :nodoc:
|
20
|
+
def initialize(file)
|
21
|
+
super
|
22
|
+
|
23
|
+
@prev_break = false
|
24
|
+
end
|
25
|
+
|
26
|
+
# @see super
|
27
|
+
def run_for_line(line, index)
|
28
|
+
if prev_break && line.empty?
|
29
|
+
puts("#{file}:#{index}: has multiple line breaks")
|
30
|
+
elsif line.empty?
|
31
|
+
@prev_break = true
|
32
|
+
else
|
33
|
+
@prev_break = false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rubomatic
|
4
|
+
module Html
|
5
|
+
module Cop
|
6
|
+
module Layout
|
7
|
+
class TrailingWhitespace < Rubomatic::Html::Cop::Layout::Base
|
8
|
+
# Name for the cop
|
9
|
+
#
|
10
|
+
# @return [String]
|
11
|
+
#
|
12
|
+
def self.name
|
13
|
+
[department, 'TrailingWhitespace'].join('/')
|
14
|
+
end
|
15
|
+
|
16
|
+
# @see super
|
17
|
+
def run_for_line(line, index)
|
18
|
+
return unless line.match?(/\s\z/i)
|
19
|
+
|
20
|
+
puts("#{file}:#{index}: has trailing whitespace")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rubomatic
|
4
|
+
module Html
|
5
|
+
module Cop
|
6
|
+
module Style
|
7
|
+
class Base < Rubomatic::Html::Cop::Base
|
8
|
+
# Department for cop
|
9
|
+
#
|
10
|
+
# @return [String]
|
11
|
+
#
|
12
|
+
def self.department
|
13
|
+
'Style'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rubomatic
|
4
|
+
module Html
|
5
|
+
module Cop
|
6
|
+
module Style
|
7
|
+
class PartialInstanceVariable < Rubomatic::Html::Cop::Style::Base
|
8
|
+
# Name for the cop
|
9
|
+
#
|
10
|
+
# @return [String]
|
11
|
+
#
|
12
|
+
def self.name
|
13
|
+
[department, 'PartialInstanceVariable'].join('/')
|
14
|
+
end
|
15
|
+
|
16
|
+
# @see super
|
17
|
+
def run_for_line(line, index)
|
18
|
+
return unless File.basename(file).match?(/^_/i)
|
19
|
+
|
20
|
+
return unless line.match?(/@/i)
|
21
|
+
|
22
|
+
puts("#{file}:#{index}: might use an instance variable")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
require_relative 'html/cop/cops'
|
5
|
+
require_relative 'html/version'
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
module Rubomatic
|
9
|
+
module Html
|
10
|
+
class Runner
|
11
|
+
PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
|
12
|
+
CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
|
13
|
+
CONFIG = ::YAML.safe_load(CONFIG_DEFAULT.read).freeze
|
14
|
+
|
15
|
+
# @return [Array<String>]
|
16
|
+
attr_accessor :files_to_lint
|
17
|
+
# @return [Hash]
|
18
|
+
attr_accessor :config
|
19
|
+
|
20
|
+
# @param linted_files [Array<String>]
|
21
|
+
#
|
22
|
+
def initialize(linted_files)
|
23
|
+
files_to_lint = Array(linted_files)
|
24
|
+
|
25
|
+
if files_to_lint.empty?
|
26
|
+
files_to_lint = Dir[File.join('app', 'views', '**', '*')]
|
27
|
+
end
|
28
|
+
|
29
|
+
@files_to_lint = files_to_lint
|
30
|
+
|
31
|
+
custom_config = ::YAML.safe_load(Pathname.new('.rubomatic-html.yml').read).freeze
|
32
|
+
|
33
|
+
config = {}
|
34
|
+
|
35
|
+
CONFIG.each do |cop, cop_config|
|
36
|
+
config[cop] = {}
|
37
|
+
config[cop][:enabled] = cop_config['Enabled']
|
38
|
+
config[cop][:exclude] = Array(cop_config['Exclude'])
|
39
|
+
|
40
|
+
if custom_config.fetch(cop, {}).has_key?('Enabled')
|
41
|
+
config[cop][:enabled] = custom_config[cop]['Enabled']
|
42
|
+
end
|
43
|
+
|
44
|
+
if custom_config.fetch(cop, {}).has_key?('Exclude')
|
45
|
+
config[cop][:exclude] = Array(custom_config[cop]['Exclude'])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
@config = config
|
50
|
+
end
|
51
|
+
|
52
|
+
# Runs all cops against all files
|
53
|
+
#
|
54
|
+
# @return [void]
|
55
|
+
#
|
56
|
+
def run
|
57
|
+
all_config = config.fetch('AllCops')
|
58
|
+
|
59
|
+
files_to_lint.each do |file|
|
60
|
+
next if all_config.fetch(:exclude).any? { |ignored| file.end_with?(ignored) }
|
61
|
+
|
62
|
+
ext = File.extname(file)
|
63
|
+
|
64
|
+
next if ext.match?(/haml/i)
|
65
|
+
|
66
|
+
check_it = ext.match?(/html/i)
|
67
|
+
check_it ||= ext.match?(/erb\z/i)
|
68
|
+
|
69
|
+
next unless check_it
|
70
|
+
|
71
|
+
run_file(file)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
# List of all cops available
|
78
|
+
#
|
79
|
+
# @return [Array<*>]
|
80
|
+
#
|
81
|
+
def all_cops
|
82
|
+
@all_cops ||= [
|
83
|
+
Rubomatic::Html::Cop::Layout::LineLength,
|
84
|
+
Rubomatic::Html::Cop::Layout::MultipleLineBreaks,
|
85
|
+
Rubomatic::Html::Cop::Layout::TrailingWhitespace,
|
86
|
+
Rubomatic::Html::Cop::Style::PartialInstanceVariable
|
87
|
+
]
|
88
|
+
end
|
89
|
+
|
90
|
+
# Runs all cops against a given file
|
91
|
+
#
|
92
|
+
# @param file [String]
|
93
|
+
#
|
94
|
+
# @return [void]
|
95
|
+
#
|
96
|
+
def run_file(file)
|
97
|
+
cops = all_cops.filter_map do |cop|
|
98
|
+
next unless config.dig(cop.name, :enabled)
|
99
|
+
|
100
|
+
cop.new(file)
|
101
|
+
end
|
102
|
+
|
103
|
+
return if cops.empty?
|
104
|
+
|
105
|
+
File.open(file).each_line(chomp: true).with_index(1) do |line, index|
|
106
|
+
cops.each do |cop|
|
107
|
+
next if config.dig(cop.class.name).fetch(:exclude, []).any? { |ignored| file.end_with?(ignored) }
|
108
|
+
|
109
|
+
cop.run_for_line(line, index)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
data/lib/rubomatic-html.rb
CHANGED
@@ -1,113 +1,3 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require_relative 'rubomatic-html/cop/cops'
|
5
|
-
require_relative 'rubomatic-html/version'
|
6
|
-
require 'yaml'
|
7
|
-
|
8
|
-
module RubomaticHtml
|
9
|
-
class Runner
|
10
|
-
PROJECT_ROOT = Pathname.new(__dir__).parent.expand_path.freeze
|
11
|
-
CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
|
12
|
-
CONFIG = ::YAML.safe_load(CONFIG_DEFAULT.read).freeze
|
13
|
-
|
14
|
-
# @return [Array<String>]
|
15
|
-
attr_accessor :files_to_lint
|
16
|
-
# @return [Hash]
|
17
|
-
attr_accessor :config
|
18
|
-
|
19
|
-
# @param linted_files [Array<String>]
|
20
|
-
#
|
21
|
-
def initialize(linted_files)
|
22
|
-
files_to_lint = Array(linted_files)
|
23
|
-
|
24
|
-
if files_to_lint.empty?
|
25
|
-
files_to_lint = Dir[File.join('app', 'views', '**', '*')]
|
26
|
-
end
|
27
|
-
|
28
|
-
@files_to_lint = files_to_lint
|
29
|
-
|
30
|
-
custom_config = ::YAML.safe_load(Pathname.new('.rubomatic-html.yml').read).freeze
|
31
|
-
|
32
|
-
config = {}
|
33
|
-
|
34
|
-
CONFIG.each do |cop, cop_config|
|
35
|
-
config[cop] = {}
|
36
|
-
config[cop][:enabled] = cop_config['Enabled']
|
37
|
-
config[cop][:exclude] = Array(cop_config['Exclude'])
|
38
|
-
|
39
|
-
if custom_config.fetch(cop, {}).has_key?('Enabled')
|
40
|
-
config[cop][:enabled] = custom_config[cop]['Enabled']
|
41
|
-
end
|
42
|
-
|
43
|
-
if custom_config.fetch(cop, {}).has_key?('Exclude')
|
44
|
-
config[cop][:exclude] = Array(custom_config[cop]['Exclude'])
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
@config = config
|
49
|
-
end
|
50
|
-
|
51
|
-
# Runs all cops against all files
|
52
|
-
#
|
53
|
-
# @return [void]
|
54
|
-
#
|
55
|
-
def run
|
56
|
-
all_config = config.fetch('AllCops')
|
57
|
-
|
58
|
-
files_to_lint.each do |file|
|
59
|
-
next if all_config.fetch(:exclude).any? { |ignored| file.end_with?(ignored) }
|
60
|
-
|
61
|
-
ext = File.extname(file)
|
62
|
-
|
63
|
-
next if ext.match?(/haml/i)
|
64
|
-
|
65
|
-
check_it = ext.match?(/html/i)
|
66
|
-
check_it ||= ext.match?(/erb\z/i)
|
67
|
-
|
68
|
-
next unless check_it
|
69
|
-
|
70
|
-
run_file(file)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
|
76
|
-
# List of all cops available
|
77
|
-
#
|
78
|
-
# @return [Array<*>]
|
79
|
-
#
|
80
|
-
def all_cops
|
81
|
-
@all_cops ||= [
|
82
|
-
RubomaticHtml::Cop::Layout::LineLength,
|
83
|
-
RubomaticHtml::Cop::Layout::MultipleLineBreaks,
|
84
|
-
RubomaticHtml::Cop::Layout::TrailingWhitespace,
|
85
|
-
RubomaticHtml::Cop::Style::PartialInstanceVariable
|
86
|
-
]
|
87
|
-
end
|
88
|
-
|
89
|
-
# Runs all cops against a given file
|
90
|
-
#
|
91
|
-
# @param file [String]
|
92
|
-
#
|
93
|
-
# @return [void]
|
94
|
-
#
|
95
|
-
def run_file(file)
|
96
|
-
cops = all_cops.filter_map do |cop|
|
97
|
-
next unless config.dig(cop.name, :enabled)
|
98
|
-
|
99
|
-
cop.new(file)
|
100
|
-
end
|
101
|
-
|
102
|
-
return if cops.empty?
|
103
|
-
|
104
|
-
File.open(file).each_line(chomp: true).with_index(1) do |line, index|
|
105
|
-
cops.each do |cop|
|
106
|
-
next if config.dig(cop.class.name).fetch(:exclude, []).any? { |ignored| file.end_with?(ignored) }
|
107
|
-
|
108
|
-
cop.run_for_line(line, index)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
3
|
+
require_relative 'rubomatic/html'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubomatic-html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.1.0.pre.rc.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brands Insurance
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05
|
11
|
+
date: 2023-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubomatic
|
@@ -44,15 +44,16 @@ files:
|
|
44
44
|
- docs/cops/style/partial_instance_variable/README.adoc
|
45
45
|
- exe/rubomatic-html
|
46
46
|
- lib/rubomatic-html.rb
|
47
|
-
- lib/rubomatic
|
48
|
-
- lib/rubomatic
|
49
|
-
- lib/rubomatic
|
50
|
-
- lib/rubomatic
|
51
|
-
- lib/rubomatic
|
52
|
-
- lib/rubomatic
|
53
|
-
- lib/rubomatic
|
54
|
-
- lib/rubomatic
|
55
|
-
- lib/rubomatic
|
47
|
+
- lib/rubomatic/html.rb
|
48
|
+
- lib/rubomatic/html/cop/base.rb
|
49
|
+
- lib/rubomatic/html/cop/cops.rb
|
50
|
+
- lib/rubomatic/html/cop/layout/base.rb
|
51
|
+
- lib/rubomatic/html/cop/layout/line_length.rb
|
52
|
+
- lib/rubomatic/html/cop/layout/multiple_line_breaks.rb
|
53
|
+
- lib/rubomatic/html/cop/layout/trailing_whitespace.rb
|
54
|
+
- lib/rubomatic/html/cop/style/base.rb
|
55
|
+
- lib/rubomatic/html/cop/style/partial_instance_variable.rb
|
56
|
+
- lib/rubomatic/html/version.rb
|
56
57
|
homepage: https://github.com/BrandsInsurance/expert-chainsaw/
|
57
58
|
licenses:
|
58
59
|
- MIT
|
@@ -72,9 +73,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
73
|
version: 3.0.1
|
73
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
75
|
requirements:
|
75
|
-
- - "
|
76
|
+
- - ">"
|
76
77
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
78
|
+
version: 1.3.1
|
78
79
|
requirements: []
|
79
80
|
rubygems_version: 3.2.15
|
80
81
|
signing_key:
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RubomaticHtml
|
4
|
-
module Cop
|
5
|
-
class Base
|
6
|
-
# @return [String]
|
7
|
-
attr_accessor :file
|
8
|
-
|
9
|
-
# Name for cop
|
10
|
-
#
|
11
|
-
# @return [String]
|
12
|
-
#
|
13
|
-
def self.name
|
14
|
-
'Base'
|
15
|
-
end
|
16
|
-
|
17
|
-
# :nodoc:
|
18
|
-
def initialize(file)
|
19
|
-
@file = file
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
# Outputs filename:line_number locations of HTML files that trigger the cop
|
25
|
-
#
|
26
|
-
# @param _line [String] the line in the html
|
27
|
-
# @param _index [Integer] the 1-index of the line
|
28
|
-
#
|
29
|
-
# @return [void]
|
30
|
-
#
|
31
|
-
def run_for_line(_line, _index)
|
32
|
-
error_message = <<~TEXT
|
33
|
-
Warning: Method `run_for_line` needs overridden! Some cops may not display failing messages.
|
34
|
-
TEXT
|
35
|
-
|
36
|
-
puts("\e[33m#{error_message}\e[0m")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RubomaticHtml
|
4
|
-
module Cop
|
5
|
-
module Layout
|
6
|
-
class LineLength < RubomaticHtml::Cop::Layout::Base
|
7
|
-
# Name for the cop
|
8
|
-
#
|
9
|
-
# @return [String]
|
10
|
-
#
|
11
|
-
def self.name
|
12
|
-
[department, 'LineLength'].join('/')
|
13
|
-
end
|
14
|
-
|
15
|
-
# @see super
|
16
|
-
def run_for_line(line, index)
|
17
|
-
return if line.size <= 120
|
18
|
-
|
19
|
-
puts("#{file}:#{index}: is over 120 characters")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RubomaticHtml
|
4
|
-
module Cop
|
5
|
-
module Layout
|
6
|
-
class MultipleLineBreaks < RubomaticHtml::Cop::Layout::Base
|
7
|
-
# @return [Boolean] tracks multiple consecutive line breaks
|
8
|
-
attr_accessor :prev_break
|
9
|
-
|
10
|
-
# Name for the cop
|
11
|
-
#
|
12
|
-
# @return [String]
|
13
|
-
#
|
14
|
-
def self.name
|
15
|
-
[department, 'MultipleLineBreaks'].join('/')
|
16
|
-
end
|
17
|
-
|
18
|
-
# :nodoc:
|
19
|
-
def initialize(file)
|
20
|
-
super
|
21
|
-
|
22
|
-
@prev_break = false
|
23
|
-
end
|
24
|
-
|
25
|
-
# @see super
|
26
|
-
def run_for_line(line, index)
|
27
|
-
if prev_break && line.empty?
|
28
|
-
puts("#{file}:#{index}: has multiple line breaks")
|
29
|
-
elsif line.empty?
|
30
|
-
@prev_break = true
|
31
|
-
else
|
32
|
-
@prev_break = false
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RubomaticHtml
|
4
|
-
module Cop
|
5
|
-
module Layout
|
6
|
-
class TrailingWhitespace < RubomaticHtml::Cop::Layout::Base
|
7
|
-
# Name for the cop
|
8
|
-
#
|
9
|
-
# @return [String]
|
10
|
-
#
|
11
|
-
def self.name
|
12
|
-
[department, 'TrailingWhitespace'].join('/')
|
13
|
-
end
|
14
|
-
|
15
|
-
# @see super
|
16
|
-
def run_for_line(line, index)
|
17
|
-
return unless line.match?(/\s\z/i)
|
18
|
-
|
19
|
-
puts("#{file}:#{index}: has trailing whitespace")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RubomaticHtml
|
4
|
-
module Cop
|
5
|
-
module Style
|
6
|
-
class PartialInstanceVariable < RubomaticHtml::Cop::Style::Base
|
7
|
-
# Name for the cop
|
8
|
-
#
|
9
|
-
# @return [String]
|
10
|
-
#
|
11
|
-
def self.name
|
12
|
-
[department, 'PartialInstanceVariable'].join('/')
|
13
|
-
end
|
14
|
-
|
15
|
-
# @see super
|
16
|
-
def run_for_line(line, index)
|
17
|
-
return unless File.basename(file).match?(/^_/i)
|
18
|
-
|
19
|
-
return unless line.match?(/@/i)
|
20
|
-
|
21
|
-
puts("#{file}:#{index}: might use an instance variable")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
File without changes
|