|
35 | 35 | # linter.colors_lowercase_linter
|
36 | 36 | # linter.no_semicolon_linter
|
37 | 37 | # linter.comment_start_linter
|
38 |
| - linter.declaration_space_linter |
39 |
| - # puts "\e[1;40m \e[1;33mThis is red text \e[0m other text" |
| 38 | + # linter.declaration_space_linter |
40 | 39 | end
|
41 | 40 | linter.report
|
42 | 41 |
|
43 | 42 | exit(0)
|
44 | 43 |
|
45 | 44 | # Checks for trailing white spaces
|
46 | 45 |
|
47 |
| -# current_file.each_with_index do |text, line| |
48 |
| -# if text.chomp[-1] == ' ' |
49 |
| -# results_log << "File: #{File.basename(current_file)} Line: #{line+1} ====> Trailing whitespace detected\n" |
50 |
| -# end |
51 |
| -# end |
| 46 | +current_file.each_with_index do |text, line| |
| 47 | + if text.chomp[-1] == ' ' |
| 48 | + results_log << "File: #{File.basename(current_file)} Line: #{line+1} ====> Trailing whitespace detected\n" |
| 49 | + end |
| 50 | +end |
52 | 51 |
|
53 | 52 | # Checks for empty lines
|
54 | 53 |
|
55 |
| -# current_file.rewind |
56 |
| -# current_file.each_with_index do |text, line| |
57 |
| -# if text.chomp.count(' ') == text.chomp.length || text.chomp.nil? |
58 |
| -# results_log << "File: #{File.basename(current_file)} Line: #{line+1} ====> Empty line detected\n" |
59 |
| -# end |
60 |
| -# end |
| 54 | +current_file.rewind |
| 55 | +current_file.each_with_index do |text, line| |
| 56 | + if text.chomp.count(' ') == text.chomp.length || text.chomp.nil? |
| 57 | + results_log << "File: #{File.basename(current_file)} Line: #{line+1} ====> Empty line detected\n" |
| 58 | + end |
| 59 | +end |
61 | 60 |
|
62 | 61 | # Checks for the space after the property
|
63 | 62 |
|
64 |
| -# current_file.rewind |
65 |
| -# current_file.each_with_index do |text, line| |
66 |
| -# text_array = text.chomp.chars |
67 |
| -# if text_array.include?(':') |
68 |
| -# if text_array[text_array.index(':')+1] != ' ' |
69 |
| -# results_log << "File: #{File.basename(current_file)} Line: #{line+1} ====> No space after colon\n" |
70 |
| -# end |
71 |
| -# end |
72 |
| -# end |
| 63 | +current_file.rewind |
| 64 | +current_file.each_with_index do |text, line| |
| 65 | + text_array = text.chomp.chars |
| 66 | + if text_array.include?(':') |
| 67 | + if text_array[text_array.index(':')+1] != ' ' |
| 68 | + results_log << "File: #{File.basename(current_file)} Line: #{line+1} ====> No space after colon\n" |
| 69 | + end |
| 70 | + end |
| 71 | +end |
73 | 72 |
|
74 | 73 | # Checks for colors lower case
|
75 | 74 |
|
76 |
| -# current_file.rewind |
77 |
| -# current_file.each_with_index do |text, line| |
78 |
| -# pound_index = text.index('#') |
79 |
| -# if pound_index != nil |
80 |
| -# semicolon_index = text.index(';') |
81 |
| -# if semicolon_index != nil |
82 |
| -# color = text[pound_index...semicolon_index] |
83 |
| -# if color != color.downcase |
84 |
| -# results_log << "File: #{File.basename(current_file)} Line: #{line+1} ====> Colors should be all lower case\n" |
85 |
| -# end |
86 |
| -# end |
87 |
| -# end |
88 |
| -# end |
| 75 | +current_file.rewind |
| 76 | +current_file.each_with_index do |text, line| |
| 77 | + pound_index = text.index('#') |
| 78 | + if pound_index != nil |
| 79 | + semicolon_index = text.index(';') |
| 80 | + if semicolon_index != nil |
| 81 | + color = text[pound_index...semicolon_index] |
| 82 | + if color != color.downcase |
| 83 | + results_log << "File: #{File.basename(current_file)} Line: #{line+1} ====> Colors should be all lower case\n" |
| 84 | + end |
| 85 | + end |
| 86 | + end |
| 87 | +end |
89 | 88 |
|
90 | 89 | # Checks for semicolon missing
|
91 | 90 |
|
92 |
| -# current_file.rewind |
93 |
| -# current_file.each_with_index do |text, line| |
94 |
| -# if text.index(';').nil? && text.index('{').nil? && text.index('}').nil? |
95 |
| -# if !text.chomp.chars.all?(' ') |
96 |
| -# results_log << "File: #{File.basename(current_file)} Line: #{line+1} ====> Missing semicolor\n" |
97 |
| -# end |
98 |
| -# end |
99 |
| -# end |
| 91 | +current_file.rewind |
| 92 | +current_file.each_with_index do |text, line| |
| 93 | + if text.index(';').nil? && text.index('{').nil? && text.index('}').nil? |
| 94 | + if !text.chomp.chars.all?(' ') |
| 95 | + results_log << "File: #{File.basename(current_file)} Line: #{line+1} ====> Missing semicolor\n" |
| 96 | + end |
| 97 | + end |
| 98 | +end |
100 | 99 |
|
101 | 100 | # Checks for space between the comment start and the content
|
102 | 101 |
|
103 |
| -# current_file.rewind |
104 |
| -# current_file.each_with_index do |text, line| |
105 |
| -# comment_index = text.index('/') |
106 |
| -# if !comment_index.nil? && text[comment_index+2] != ' ' |
107 |
| -# results_log << "File: #{File.basename(current_file)} Line: #{line+1} ====> Missing space after between /* and content\n" |
108 |
| -# end |
109 |
| -# end |
| 102 | +current_file.rewind |
| 103 | +current_file.each_with_index do |text, line| |
| 104 | + comment_index = text.index('/') |
| 105 | + if !comment_index.nil? && text[comment_index+2] != ' ' |
| 106 | + results_log << "File: #{File.basename(current_file)} Line: #{line+1} ====> Missing space after between /* and content\n" |
| 107 | + end |
| 108 | +end |
110 | 109 |
|
111 | 110 | # Checks for space between the declaration and the {
|
112 | 111 |
|
113 |
| -# current_file.rewind |
114 |
| -# current_file.each_with_index do |text, line| |
115 |
| -# bracket_index = text.index('{') |
116 |
| -# if !bracket_index.nil? && text[bracket_index-1] != ' ' |
117 |
| -# results_log << "File: #{File.basename(current_file)} Line: #{line+1} ====> Missing space before the opening bracket\n" |
118 |
| -# end |
119 |
| -# end |
| 112 | +current_file.rewind |
| 113 | +current_file.each_with_index do |text, line| |
| 114 | + bracket_index = text.index('{') |
| 115 | + if !bracket_index.nil? && text[bracket_index-1] != ' ' |
| 116 | + results_log << "File: #{File.basename(current_file)} Line: #{line+1} ====> Missing space before the opening bracket\n" |
| 117 | + end |
| 118 | +end |
120 | 119 |
|
121 | 120 | # Type of line
|
122 | 121 |
|
|
0 commit comments