Add vera rules to check consecutive and trailing empty lines (#3540)

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
This commit is contained in:
Dániel Bátyai
2020-02-03 16:39:04 +01:00
committed by GitHub
parent 563a5d93e9
commit a78c8d4f16
63 changed files with 68 additions and 87 deletions
-2
View File
@@ -221,8 +221,6 @@ def generate_header(gen_file):
def generate_magic_string_defs(gen_file, defs):
print(file=gen_file) # empty line separator
last_guards = set([()])
for str_ref, str_value, guards in defs:
if last_guards != guards:
+2
View File
@@ -11,6 +11,8 @@ set rules {
jerry_no_space_before_closing_parentheses
jerry_no_tabs
jerry_no_trailing_spaces
jerry_no_leading_or_trailing_empty_line
jerry_no_consecutive_empty_lines
jerry_pointer_declarator_space
jerry_switch_case
jerry_typecast_space_parentheses
@@ -0,0 +1,36 @@
#!/usr/bin/tclsh
# Copyright JS Foundation and other contributors, http://js.foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set maxEmptyLines 1
foreach f [getSourceFileNames] {
set lineNumber 1
set emptyCount 0
set reported false
foreach line [getAllLines $f] {
if {[string trim $line] == ""} {
incr emptyCount
if {$emptyCount > $maxEmptyLines && $reported == "false"} {
report $f $lineNumber "too many consecutive empty lines"
set reported true
}
} else {
set emptyCount 0
set reported false
}
incr lineNumber
}
}
@@ -0,0 +1,30 @@
#!/usr/bin/tclsh
# Copyright JS Foundation and other contributors, http://js.foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
foreach f [getSourceFileNames] {
set lineCount [getLineCount $f]
if {$lineCount > 0} {
set firstLine [getLine $f 1]
if {[string trim $firstLine] == ""} {
report $f 1 "leading empty line(s)"
}
set lastLine [getLine $f $lineCount]
if {[string trim $lastLine] == ""} {
report $f $lineCount "trailing empty line(s)"
}
}
}