Skip to content

Fix: code-related vera++ rules should not be enforced in comments #973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/tclsh

# Copyright 2015 Samsung Electronics Co., Ltd.
# Copyright 2015-2016 Samsung Electronics Co., Ltd.
# Copyright 2016 University of Szeged
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,12 +15,43 @@
# See the License for the specific language governing permissions and
# limitations under the License.

foreach f [getSourceFileNames] {
set lineNumber 1
foreach line [getAllLines $f] {
if {[regexp {[[:graph:]][[:blank:]]+\)} $line]} {
report $f $lineNumber "there should be no blank characters before closing parentheses"
proc check_part_of_the_file {file line_num col_start col_end} {
if {$col_start == $col_end} {
return
}

set line [getLine $file $line_num]
set line [string range $line $col_start $col_end]

if {[regexp {[[:graph:]][[:blank:]]+\)} $line]} {
report $file $line_num "there should be no blank characters before closing parentheses"
}
}

foreach fileName [getSourceFileNames] {
set checkLine 1
set checkColStart 0
set seenOmitToken false
foreach token [getTokens $fileName 1 0 -1 -1 {}] {
set lineNumber [lindex $token 1]
set colNumber [lindex $token 2]
set tokenType [lindex $token 3]

if {$checkLine != $lineNumber} {
if {!$seenOmitToken} {
check_part_of_the_file $fileName $checkLine $checkColStart end
}
set checkColStart $colNumber
set checkLine $lineNumber
} elseif {$seenOmitToken} {
set checkColStart $colNumber
}

if {$tokenType in {ccomment cppcomment stringlit}} {
check_part_of_the_file $fileName $checkLine $checkColStart $colNumber
set seenOmitToken true
} else {
set seenOmitToken false
}
incr lineNumber
}
}
47 changes: 39 additions & 8 deletions tools/vera++/scripts/rules/jerry_pointer_declarator_space.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,45 @@
# See the License for the specific language governing permissions and
# limitations under the License.

foreach f [getSourceFileNames] {
set lineNumber 1
foreach line [getAllLines $f] {
if {[regexp {\w\*\s\w+} $line]
|| [regexp {\w\*\)} $line]
|| [regexp {\w\*$} $line]} {
report $f $lineNumber "there should be a space between the referenced type and the pointer declarator."
proc check_part_of_the_file {file line_num col_start col_end} {
if {$col_start == $col_end} {
return
}

set line [getLine $file $line_num]
set line [string range $line $col_start $col_end]

if {[regexp {\w\*\s\w+} $line]
|| [regexp {\w\*\)} $line]
|| [regexp {\w\*$} $line]} {
report $file $line_num "there should be a space between the referenced type and the pointer declarator."
}
}

foreach fileName [getSourceFileNames] {
set checkLine 1
set checkColStart 0
set seenOmitToken false
foreach token [getTokens $fileName 1 0 -1 -1 {}] {
set lineNumber [lindex $token 1]
set colNumber [lindex $token 2]
set tokenType [lindex $token 3]

if {$checkLine != $lineNumber} {
if {!$seenOmitToken} {
check_part_of_the_file $fileName $checkLine $checkColStart end
}
set checkColStart $colNumber
set checkLine $lineNumber
} elseif {$seenOmitToken} {
set checkColStart $colNumber
}

if {$tokenType in {ccomment cppcomment stringlit}} {
check_part_of_the_file $fileName $checkLine $checkColStart $colNumber
set seenOmitToken true
} else {
set seenOmitToken false
}
incr lineNumber
}
}