Add indentation checks for code inside classes and fix appeared issues.
Fix asserts in test_recordset.cpp. JerryScript-DCO-1.0-Signed-off-by: Andrey Shitov a.shitov@samsung.com
This commit is contained in:
@@ -138,6 +138,7 @@ class rcs_recordset_t
|
||||
*/
|
||||
static const uint32_t _fields_offset_begin = _type_field_pos + _type_field_width;
|
||||
};
|
||||
|
||||
private:
|
||||
friend class rcs_record_iterator_t;
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "jrt.h"
|
||||
#include "mem-allocator.h"
|
||||
#include "rcs-recordset.h"
|
||||
@@ -243,23 +241,23 @@ main (int __attr_unused___ argc,
|
||||
{
|
||||
if (rand () % 2)
|
||||
{
|
||||
assert (type_one_records_number < test_sub_iters);
|
||||
JERRY_ASSERT (type_one_records_number < test_sub_iters);
|
||||
|
||||
uint32_t elements_count = ((uint32_t) rand ()) % test_max_type_one_record_elements;
|
||||
type_one_record_element_counts[type_one_records_number] = elements_count;
|
||||
type_one_records[type_one_records_number] = storage.create_record_type_one (elements_count);
|
||||
|
||||
assert (type_one_records[type_one_records_number] != NULL);
|
||||
JERRY_ASSERT (type_one_records[type_one_records_number] != NULL);
|
||||
|
||||
type_one_records_number++;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert (type_two_records_number < test_sub_iters);
|
||||
JERRY_ASSERT (type_two_records_number < test_sub_iters);
|
||||
|
||||
type_two_records[type_two_records_number] = storage.create_record_type_two ();
|
||||
|
||||
assert (type_two_records[type_two_records_number] != NULL);
|
||||
JERRY_ASSERT (type_two_records[type_two_records_number] != NULL);
|
||||
|
||||
type_two_records_number++;
|
||||
}
|
||||
@@ -271,13 +269,13 @@ main (int __attr_unused___ argc,
|
||||
|
||||
if (type_one_records_number == 0)
|
||||
{
|
||||
assert (type_two_records_number != 0);
|
||||
JERRY_ASSERT (type_two_records_number != 0);
|
||||
|
||||
free_type_one = false;
|
||||
}
|
||||
else if (type_two_records_number == 0)
|
||||
{
|
||||
assert (type_one_records_number != 0);
|
||||
JERRY_ASSERT (type_one_records_number != 0);
|
||||
|
||||
free_type_one = true;
|
||||
}
|
||||
@@ -288,10 +286,10 @@ main (int __attr_unused___ argc,
|
||||
|
||||
if (free_type_one)
|
||||
{
|
||||
assert (type_one_records_number > 0);
|
||||
JERRY_ASSERT (type_one_records_number > 0);
|
||||
int index_to_free = (rand () % type_one_records_number);
|
||||
|
||||
assert (index_to_free >= 0 && index_to_free < type_one_records_number);
|
||||
JERRY_ASSERT (index_to_free >= 0 && index_to_free < type_one_records_number);
|
||||
|
||||
storage.free_record_type_one (type_one_records[index_to_free]);
|
||||
|
||||
@@ -306,10 +304,10 @@ main (int __attr_unused___ argc,
|
||||
}
|
||||
else
|
||||
{
|
||||
assert (type_two_records_number > 0);
|
||||
JERRY_ASSERT (type_two_records_number > 0);
|
||||
int index_to_free = (rand () % type_two_records_number);
|
||||
|
||||
assert (index_to_free >= 0 && index_to_free < type_two_records_number);
|
||||
JERRY_ASSERT (index_to_free >= 0 && index_to_free < type_two_records_number);
|
||||
|
||||
storage.free_record_type_two (type_two_records[index_to_free]);
|
||||
|
||||
|
||||
@@ -22,7 +22,9 @@ foreach fileName [getSourceFileNames] {
|
||||
set is_in_comment "no"
|
||||
set is_in_pp_define "no"
|
||||
set is_in_class "no"
|
||||
set is_in_template "no"
|
||||
set parentheses_level 0
|
||||
set template_brackets_level 0
|
||||
|
||||
foreach token [getTokens $fileName 1 0 -1 -1 {}] {
|
||||
set type [lindex $token 3]
|
||||
@@ -36,6 +38,8 @@ foreach fileName [getSourceFileNames] {
|
||||
set is_in_pp_define "no"
|
||||
} elseif {$type == "class"} {
|
||||
set is_in_class "yes"
|
||||
} elseif {$type == "template"} {
|
||||
set is_in_template "yes"
|
||||
} elseif {$is_in_class == "yes" && $type == "semicolon" && $indent == 0} {
|
||||
set is_in_class "no"
|
||||
} elseif {$type == "ccomment"} {
|
||||
@@ -52,17 +56,20 @@ foreach fileName [getSourceFileNames] {
|
||||
incr indent -2
|
||||
}
|
||||
|
||||
if {$is_in_pp_define == "no" && $is_in_comment == "no" && $is_in_class == "no" && $parentheses_level == 0} {
|
||||
if {$is_in_pp_define == "no" && $is_in_comment == "no" && $parentheses_level == 0 &&
|
||||
$is_in_template == "no"} {
|
||||
set line [getLine $fileName $lineNumber]
|
||||
|
||||
if {$lineNumber != $lastCheckedLineNumber} {
|
||||
if {[string length $line] == 0} {
|
||||
}
|
||||
|
||||
if {[regexp {^[[:blank:]]*} $line match]} {
|
||||
set real_indent [string length $match]
|
||||
if {$indent != $real_indent} {
|
||||
if {![regexp {^[[:alnum:]_]{1,}:$} $line] || $real_indent != 0} {
|
||||
if {[regexp {^[[:blank:]]*(private:|public:|protected:)} $line]} {
|
||||
if {$indent != $real_indent + 2} {
|
||||
set exp_indent [expr {$indent - 2}]
|
||||
report $fileName $lineNumber "Indentation: $real_indent -> $exp_indent. Line: '$line'"
|
||||
}
|
||||
} elseif {![regexp {^[[:alnum:]_]{1,}:$} $line] || $real_indent != 0} {
|
||||
report $fileName $lineNumber "Indentation: $real_indent -> $indent. Line: '$line'"
|
||||
}
|
||||
}
|
||||
@@ -84,7 +91,7 @@ foreach fileName [getSourceFileNames] {
|
||||
}
|
||||
}
|
||||
if {$type == "rightbrace"} {
|
||||
if {![regexp {^[[:blank:]]*\}((( [a-z_\(][a-z0-9_\(\)]{0,}){1,})?;| /\*.*\*/| //.*)?$} $line]
|
||||
if {![regexp {^[[:blank:]]*\};?((( [a-z_\(][a-z0-9_\(\)]{0,}){1,})?;| /\*.*\*/| //.*)?$} $line]
|
||||
&& ![regexp {[^\{=]=[^\{=]\{.*\}[,;]?} $line]} {
|
||||
report $fileName $lineNumber "Right brace is not the only non-space character in the line and \
|
||||
is not single right brace followed by \[a-z0-9_() \] string and single semicolon character: '$line'"
|
||||
@@ -100,6 +107,17 @@ foreach fileName [getSourceFileNames] {
|
||||
incr parentheses_level -1
|
||||
}
|
||||
|
||||
if {$is_in_template == "yes"} {
|
||||
if {$type == "less"} {
|
||||
incr template_brackets_level
|
||||
} elseif {$type == "greater"} {
|
||||
incr template_brackets_level -1
|
||||
if {$template_brackets_level == 0} {
|
||||
set is_in_template "no"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
set lastCheckedLineNumber $lineNumber
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user