From a78c8d4f1683f2641f91682e279d8e7b29b3d7fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20B=C3=A1tyai?= Date: Mon, 3 Feb 2020 16:39:04 +0100 Subject: [PATCH] Add vera rules to check consecutive and trailing empty lines (#3540) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu --- jerry-core/api/jerry-snapshot.c | 1 - jerry-core/api/jerry.c | 1 - jerry-core/config.h | 2 -- jerry-core/debugger/debugger.c | 2 -- jerry-core/ecma/base/ecma-helpers-string.c | 1 - jerry-core/ecma/base/ecma-module.c | 1 - jerry-core/ecma/base/ecma-property-hashmap.c | 1 - jerry-core/ecma/base/ecma-property-hashmap.h | 1 - ...-builtin-array-prototype-unscopables.inc.h | 1 - .../ecma-builtin-array-prototype.c | 2 -- .../ecma/builtin-objects/ecma-builtin-date.c | 1 - .../builtin-objects/ecma-builtin-global.c | 2 -- .../builtin-objects/ecma-builtin-global.inc.h | 1 - .../ecma-builtin-helpers-error.c | 1 - .../builtin-objects/ecma-builtin-helpers.c | 2 -- .../ecma/builtin-objects/ecma-builtin-math.c | 1 - .../ecma-builtin-object-prototype.c | 1 - .../builtin-objects/ecma-builtin-object.c | 1 - .../builtin-objects/ecma-builtin-promise.c | 2 -- .../ecma-builtin-string-iterator-prototype.c | 1 - .../ecma-builtin-string-prototype.c | 1 - .../ecma/builtin-objects/ecma-builtins.inc.h | 1 - .../ecma-builtin-typedarray-prototype.c | 2 -- .../ecma/operations/ecma-array-object.c | 1 - .../ecma/operations/ecma-array-object.h | 1 - .../ecma/operations/ecma-arraybuffer-object.c | 1 - .../ecma/operations/ecma-container-object.c | 2 -- .../ecma/operations/ecma-function-object.c | 1 - jerry-core/ecma/operations/ecma-lex-env.c | 1 - .../ecma/operations/ecma-objects-general.c | 1 - jerry-core/ecma/operations/ecma-objects.c | 2 -- .../ecma/operations/ecma-string-object.h | 1 - .../ecma/operations/ecma-typedarray-object.c | 8 ----- jerry-core/include/jerryscript-core.h | 1 - jerry-core/jmem/jmem-allocator.c | 1 - jerry-core/jmem/jmem-heap.c | 1 - jerry-core/lit/lit-magic-strings.inc.h | 1 - jerry-core/parser/js/js-lexer.c | 1 - jerry-core/vm/vm.h | 1 - jerry-ext/arg/arg.c | 1 - .../include/jerryscript-ext/handle-scope.h | 1 - jerry-ext/module/module.c | 1 - jerry-libm/jerry-libm-internal.h | 1 - jerry-libm/sqrt.c | 4 --- jerry-main/benchmarking.c | 1 - jerry-main/libfuzzer.c | 1 - jerry-main/main-unix.c | 2 -- jerry-port/default/default-date.c | 1 - .../test-api-binary-operations-arithmetics.c | 2 -- tests/unit-core/test-api.c | 3 -- tests/unit-core/test-context-data.c | 2 -- tests/unit-core/test-mem-stats.c | 1 - tests/unit-core/test-native-callback-nested.c | 1 - tests/unit-core/test-promise.c | 1 - tests/unit-core/test-resource-name.c | 1 - tests/unit-core/test-stringbuilder.c | 1 - tests/unit-core/test-to-integer.c | 2 -- tests/unit-ext/test-ext-arg.c | 2 -- tests/unit-ext/test-ext-method-register.c | 1 - tools/gen-magic-strings.py | 2 -- tools/vera++/profiles/jerry | 2 ++ .../jerry_no_consecutive_empty_lines.tcl | 36 +++++++++++++++++++ ...erry_no_leading_or_trailing_empty_line.tcl | 30 ++++++++++++++++ 63 files changed, 68 insertions(+), 87 deletions(-) create mode 100644 tools/vera++/scripts/rules/jerry_no_consecutive_empty_lines.tcl create mode 100644 tools/vera++/scripts/rules/jerry_no_leading_or_trailing_empty_line.tcl diff --git a/jerry-core/api/jerry-snapshot.c b/jerry-core/api/jerry-snapshot.c index 30d112e30..309d5cdfe 100644 --- a/jerry-core/api/jerry-snapshot.c +++ b/jerry-core/api/jerry-snapshot.c @@ -1758,7 +1758,6 @@ jerry_get_literals_from_snapshot (const uint32_t *snapshot_p, /**< input snapsho #endif /* ENABLED (JERRY_SNAPSHOT_SAVE) */ } /* jerry_get_literals_from_snapshot */ - /** * Generate snapshot function from specified source and arguments * diff --git a/jerry-core/api/jerry.c b/jerry-core/api/jerry.c index fe64bb855..8840e7502 100644 --- a/jerry-core/api/jerry.c +++ b/jerry-core/api/jerry.c @@ -2885,7 +2885,6 @@ jerry_objects_foreach_by_native_info (const jerry_object_native_info_t *native_i ecma_native_pointer_t *native_pointer_p; - jmem_cpointer_t iter_cp = JERRY_CONTEXT (ecma_gc_objects_cp); while (iter_cp != JMEM_CP_NULL) diff --git a/jerry-core/config.h b/jerry-core/config.h index a2087ca4c..9d0a66383 100644 --- a/jerry-core/config.h +++ b/jerry-core/config.h @@ -455,7 +455,6 @@ # define JERRY_ATTR_GLOBAL_HEAP #endif /* !defined (JERRY_ATTR_GLOBAL_HEAP) */ - /** * Sanity check for macros to see if the values are 0 or 1 * @@ -653,7 +652,6 @@ # error "Invalid value for 'JERRY_VM_EXEC_STOP' macro." #endif - #define ENABLED(FEATURE) ((FEATURE) == 1) #define DISABLED(FEATURE) ((FEATURE) != 1) diff --git a/jerry-core/debugger/debugger.c b/jerry-core/debugger/debugger.c index f3b207f6d..3f5d6e8a4 100644 --- a/jerry-core/debugger/debugger.c +++ b/jerry-core/debugger/debugger.c @@ -1150,7 +1150,6 @@ jerry_debugger_receive (jerry_debugger_uint8_data_t **message_data_p) /**< [out] } } /* jerry_debugger_receive */ - #undef JERRY_DEBUGGER_CHECK_PACKET_SIZE /** @@ -1214,7 +1213,6 @@ jerry_debugger_send_type (jerry_debugger_header_type_t type) /**< message type * jerry_debugger_send (sizeof (jerry_debugger_send_type_t)); } /* jerry_debugger_send_type */ - /** * Send the type signal to the client. * diff --git a/jerry-core/ecma/base/ecma-helpers-string.c b/jerry-core/ecma/base/ecma-helpers-string.c index f08975690..805dc2e9d 100644 --- a/jerry-core/ecma/base/ecma-helpers-string.c +++ b/jerry-core/ecma/base/ecma-helpers-string.c @@ -676,7 +676,6 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */ cesu8_string2_p, cesu8_string2_size); - if (magic_string_id != LIT_MAGIC_STRING__COUNT) { ecma_deref_ecma_string (string1_p); diff --git a/jerry-core/ecma/base/ecma-module.c b/jerry-core/ecma/base/ecma-module.c index b2bbd591d..3f176ec5b 100644 --- a/jerry-core/ecma/base/ecma-module.c +++ b/jerry-core/ecma/base/ecma-module.c @@ -79,7 +79,6 @@ ecma_module_create_normalized_path (const uint8_t *char_p, /**< module specifier ECMA_MODULE_MAX_PATH, (char *) module_path_p); - if (normalized_size > 0) { /* Convert the normalized path to cesu8. */ diff --git a/jerry-core/ecma/base/ecma-property-hashmap.c b/jerry-core/ecma/base/ecma-property-hashmap.c index a3ab4248f..f86829e30 100644 --- a/jerry-core/ecma/base/ecma-property-hashmap.c +++ b/jerry-core/ecma/base/ecma-property-hashmap.c @@ -245,7 +245,6 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */ uint32_t mask = hashmap_p->max_property_count - 1; entry_index &= mask; - #ifndef JERRY_NDEBUG /* See the comment for this variable in ecma_property_hashmap_create. */ uint32_t start_entry_index = entry_index; diff --git a/jerry-core/ecma/base/ecma-property-hashmap.h b/jerry-core/ecma/base/ecma-property-hashmap.h index 13b417468..62b69445f 100644 --- a/jerry-core/ecma/base/ecma-property-hashmap.h +++ b/jerry-core/ecma/base/ecma-property-hashmap.h @@ -72,7 +72,6 @@ void ecma_property_hashmap_insert (ecma_object_t *object_p, ecma_string_t *name_ ecma_property_hashmap_delete_status ecma_property_hashmap_delete (ecma_object_t *object_p, jmem_cpointer_t name_cp, ecma_property_t *property_p); - ecma_property_t *ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, ecma_string_t *name_p, jmem_cpointer_t *property_real_name_cp); #endif /* ENABLED (JERRY_PROPRETY_HASHMAP) */ diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype-unscopables.inc.h b/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype-unscopables.inc.h index 287635fa8..4410c50c7 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype-unscopables.inc.h +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype-unscopables.inc.h @@ -19,7 +19,6 @@ #include "ecma-builtin-helpers-macro-defines.inc.h" - #if ENABLED (JERRY_ES2015) SIMPLE_VALUE (LIT_MAGIC_STRING_COPY_WITHIN, diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c index b2f3fc0a2..8030ccd8c 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c @@ -1292,7 +1292,6 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu return get_value; } - if (ecma_is_value_found (get_value)) { /* 9.c.ii */ @@ -1944,7 +1943,6 @@ ecma_builtin_array_prototype_object_map (ecma_value_t arg1, /**< callbackfn */ mapped_value, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); - ecma_free_value (mapped_value); ecma_free_value (current_value); #if ENABLED (JERRY_ES2015) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-date.c b/jerry-core/ecma/builtin-objects/ecma-builtin-date.c index b4b839ef7..c0f78603d 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-date.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-date.c @@ -183,7 +183,6 @@ ecma_date_parse_month_name (const lit_utf8_byte_t **str_p, /**< pointer to the c return 0; } /* ecma_date_parse_month_name */ - /** * Calculate MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli)) for Date constructor and UTC * diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-global.c b/jerry-core/ecma/builtin-objects/ecma-builtin-global.c index 717aa7383..b7692d642 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-global.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-global.c @@ -387,7 +387,6 @@ ecma_builtin_global_object_parse_float (const lit_utf8_byte_t *string_buff, /**< } } - /* Set end position to the end of whole part. */ end_p = str_curr_p; if (str_curr_p < str_end_p) @@ -425,7 +424,6 @@ ecma_builtin_global_object_parse_float (const lit_utf8_byte_t *string_buff, /**< } } - if (str_curr_p < str_end_p) { current = *str_curr_p++; diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-global.inc.h b/jerry-core/ecma/builtin-objects/ecma-builtin-global.inc.h index ba8c9a5aa..aa2e3efe8 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-global.inc.h +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-global.inc.h @@ -146,7 +146,6 @@ OBJECT_VALUE (LIT_MAGIC_STRING_REFLECT_UL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE) #endif /* ENABLED (JERRY_ES2015_BUILTIN_REFLECT) */ - #if ENABLED (JERRY_BUILTIN_JSON) /* ECMA-262 v5, 15.1.5.2 */ OBJECT_VALUE (LIT_MAGIC_STRING_JSON_U, diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-error.c b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-error.c index 9e2ce6214..25239bd28 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-error.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-error.c @@ -72,4 +72,3 @@ ecma_builtin_helper_error_dispatch_call (ecma_standard_error_t error_type, /**< * @} * @} */ - diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c index 540d8f5cb..9db4a6dc0 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c @@ -220,7 +220,6 @@ ecma_builtin_helper_get_to_locale_string_at_index (ecma_object_t *obj_p, /**< th ecma_value_t index_obj_value = ecma_op_to_object (index_value); - if (ECMA_IS_VALUE_ERROR (index_obj_value)) { ecma_free_value (index_value); @@ -265,7 +264,6 @@ cleanup: return ret_string_p; } /* ecma_builtin_helper_get_to_locale_string_at_index */ - /** * The Object.keys and Object.getOwnPropertyNames routine's common part. * diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-math.c b/jerry-core/ecma/builtin-objects/ecma-builtin-math.c index a85f04230..15f7a704c 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-math.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-math.c @@ -444,7 +444,6 @@ ecma_builtin_math_dispatch_routine (uint16_t builtin_routine_id, /**< built-in w arguments_number); } - JERRY_ASSERT (builtin_routine_id == ECMA_MATH_OBJECT_RANDOM); return ecma_builtin_math_object_random (); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-object-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-object-prototype.c index 2898fd53e..7a32f6099 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-object-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-object-prototype.c @@ -50,7 +50,6 @@ enum ECMA_OBJECT_PROTOTYPE_PROPERTY_IS_ENUMERABLE, }; - #define BUILTIN_INC_HEADER_NAME "ecma-builtin-object-prototype.inc.h" #define BUILTIN_UNDERSCORED_ID object_prototype #include "ecma-builtin-internal-routines-template.inc.h" diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-object.c b/jerry-core/ecma/builtin-objects/ecma-builtin-object.c index 1b536b951..be59d07b2 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-object.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-object.c @@ -180,7 +180,6 @@ ecma_set_prototype_of (ecma_value_t o_value, /**< O */ ECMA_SET_NON_NULL_POINTER (v_cp, ecma_get_object_from_value (v_value)); } - /* 3., 4. */ if (v_cp == o_p->u2.prototype_cp) { diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-promise.c b/jerry-core/ecma/builtin-objects/ecma-builtin-promise.c index 875d94794..0d7b9cc70 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-promise.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-promise.c @@ -133,7 +133,6 @@ ecma_builtin_promise_perform_race (ecma_value_t iterator, /**< the iterator for JERRY_ASSERT (ecma_is_value_object (iterator) && ecma_is_value_object (capability)); - ecma_object_t *capability_obj_p = ecma_get_object_from_value (capability); /* 1. */ while (true) @@ -290,7 +289,6 @@ ecma_builtin_promise_all_handler (const ecma_value_t function, /**< the function argv[0], false); - /* 9-10. */ ecma_value_t ret = ECMA_VALUE_UNDEFINED; if (ecma_builtin_promise_remaining_inc_or_dec (remaining, false) == 0) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c index 4df11a12e..6ce4d272e 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c @@ -77,7 +77,6 @@ ecma_builtin_string_iterator_prototype_object_next (ecma_value_t this_val) /**< JERRY_ASSERT (ecma_is_value_string (iterated_value)); - ecma_string_t *string_p = ecma_get_string_from_value (iterated_value); /* 6. */ diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c index 35a62871a..1eb73ba19 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c @@ -715,7 +715,6 @@ ecma_builtin_string_prototype_object_slice (ecma_string_t *get_string_val, /**< return ecma_make_string_value (new_str_p); } /* ecma_builtin_string_prototype_object_slice */ - /** * The String.prototype object's 'split' routine * diff --git a/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h b/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h index 67494b84e..a50ad4673 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h +++ b/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h @@ -362,7 +362,6 @@ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_FLOAT64ARRAY, float64array) #endif /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */ - BUILTIN (ECMA_BUILTIN_ID_INT8ARRAY_PROTOTYPE, ECMA_OBJECT_TYPE_GENERAL, ECMA_BUILTIN_ID_TYPEDARRAY_PROTOTYPE, diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c index bb9c0fd72..01b58c293 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c @@ -332,7 +332,6 @@ ecma_builtin_typedarray_prototype_for_each (ecma_value_t this_arg, /**< this arg TYPEDARRAY_ROUTINE_FOREACH); } /* ecma_builtin_typedarray_prototype_for_each */ - #if ENABLED (JERRY_ES2015) /** @@ -1743,7 +1742,6 @@ ecma_builtin_typedarray_prototype_index_of (ecma_value_t this_arg, /**< this arg : (uint32_t) (info.length + num_var)); } - ecma_number_t search_num = ecma_get_number_from_value (args[0]); ecma_typedarray_getter_fn_t getter_cb = ecma_get_typedarray_getter_fn (info.id); diff --git a/jerry-core/ecma/operations/ecma-array-object.c b/jerry-core/ecma/operations/ecma-array-object.c index e0c1ced72..3e537729e 100644 --- a/jerry-core/ecma/operations/ecma-array-object.c +++ b/jerry-core/ecma/operations/ecma-array-object.c @@ -737,7 +737,6 @@ ecma_op_array_species_create (ecma_object_t *original_array_p, /**< The object f &len_val, 1); - ecma_deref_object (ctor_object_p); ecma_free_value (len_val); return ret_val; diff --git a/jerry-core/ecma/operations/ecma-array-object.h b/jerry-core/ecma/operations/ecma-array-object.h index e88d0462d..761b6799d 100644 --- a/jerry-core/ecma/operations/ecma-array-object.h +++ b/jerry-core/ecma/operations/ecma-array-object.h @@ -25,7 +25,6 @@ * @{ */ - /** * Maximum number of new array holes in a fast mode access array. * If the number of new holes exceeds this limit, the array is converted back diff --git a/jerry-core/ecma/operations/ecma-arraybuffer-object.c b/jerry-core/ecma/operations/ecma-arraybuffer-object.c index 61d058fa5..71a610cc9 100644 --- a/jerry-core/ecma/operations/ecma-arraybuffer-object.c +++ b/jerry-core/ecma/operations/ecma-arraybuffer-object.c @@ -92,7 +92,6 @@ ecma_arraybuffer_new_object_external (ecma_length_t length, /**< length of the b return object_p; } /* ecma_arraybuffer_new_object_external */ - /** * ArrayBuffer object creation operation. * diff --git a/jerry-core/ecma/operations/ecma-container-object.c b/jerry-core/ecma/operations/ecma-container-object.c index d9b5b3969..94628e0a0 100644 --- a/jerry-core/ecma/operations/ecma-container-object.c +++ b/jerry-core/ecma/operations/ecma-container-object.c @@ -201,7 +201,6 @@ ecma_op_container_create (const ecma_value_t *arguments_list_p, /**< arguments l ecma_deref_object (next_object_p); } - if (ECMA_IS_VALUE_ERROR (result)) { ecma_op_iterator_close (iter); @@ -678,7 +677,6 @@ ecma_op_container_delete (ecma_value_t this_arg, /**< this argument */ return ECMA_VALUE_FALSE; } - ecma_named_data_property_assign_value ((ecma_object_t *) container_p, ECMA_PROPERTY_VALUE_PTR (property_p), ECMA_VALUE_EMPTY); diff --git a/jerry-core/ecma/operations/ecma-function-object.c b/jerry-core/ecma/operations/ecma-function-object.c index 863203d58..0fc2cb12a 100644 --- a/jerry-core/ecma/operations/ecma-function-object.c +++ b/jerry-core/ecma/operations/ecma-function-object.c @@ -681,7 +681,6 @@ ecma_op_function_has_instance (ecma_object_t *func_obj_p, /**< Function object * return result; } /* ecma_op_function_has_instance */ - #if ENABLED (JERRY_ES2015) /** * Indicates whether the class has been invoked with 'new'. diff --git a/jerry-core/ecma/operations/ecma-lex-env.c b/jerry-core/ecma/operations/ecma-lex-env.c index 5ac38b035..76c57a033 100644 --- a/jerry-core/ecma/operations/ecma-lex-env.c +++ b/jerry-core/ecma/operations/ecma-lex-env.c @@ -289,7 +289,6 @@ ecma_op_delete_binding (ecma_object_t *lex_env_p, /**< lexical environment */ && ecma_is_lexical_environment (lex_env_p)); JERRY_ASSERT (name_p != NULL); - if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE) { ecma_property_t *prop_p = ecma_find_named_property (lex_env_p, name_p); diff --git a/jerry-core/ecma/operations/ecma-objects-general.c b/jerry-core/ecma/operations/ecma-objects-general.c index c7ed458b0..90506466f 100644 --- a/jerry-core/ecma/operations/ecma-objects-general.c +++ b/jerry-core/ecma/operations/ecma-objects-general.c @@ -418,7 +418,6 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob JERRY_ASSERT (property_desc_type == ECMA_PROPERTY_TYPE_GENERIC || property_desc_type == ECMA_PROPERTY_TYPE_NAMEDDATA); - ecma_property_value_t *new_prop_value_p = ecma_create_named_data_property (object_p, property_name_p, prop_attributes, diff --git a/jerry-core/ecma/operations/ecma-objects.c b/jerry-core/ecma/operations/ecma-objects.c index c9207f95c..e2e0c72d8 100644 --- a/jerry-core/ecma/operations/ecma-objects.c +++ b/jerry-core/ecma/operations/ecma-objects.c @@ -165,7 +165,6 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */ return ECMA_PROPERTY_TYPE_NOT_FOUND; } - break; } #if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) @@ -2339,7 +2338,6 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */ JMEM_FINALIZE_LOCAL_ARRAY (names_p); - if (!is_with_prototype_chain || prototype_chain_iter_p->u2.prototype_cp == JMEM_CP_NULL) { break; diff --git a/jerry-core/ecma/operations/ecma-string-object.h b/jerry-core/ecma/operations/ecma-string-object.h index 640524106..7fdacebcd 100644 --- a/jerry-core/ecma/operations/ecma-string-object.h +++ b/jerry-core/ecma/operations/ecma-string-object.h @@ -34,7 +34,6 @@ ecma_op_string_list_lazy_property_names (ecma_object_t *obj_p, ecma_collection_t *main_collection_p, ecma_collection_t *non_enum_collection_p); - /** * @} * @} diff --git a/jerry-core/ecma/operations/ecma-typedarray-object.c b/jerry-core/ecma/operations/ecma-typedarray-object.c index c09d38e3e..e35b750e5 100644 --- a/jerry-core/ecma/operations/ecma-typedarray-object.c +++ b/jerry-core/ecma/operations/ecma-typedarray-object.c @@ -123,7 +123,6 @@ ecma_typedarray_get_double_element (lit_utf8_byte_t *src) /**< the location in t return (ecma_number_t) num; } /* ecma_typedarray_get_double_element */ - /** * Normalize the given ecma_number_t to an uint32_t value */ @@ -169,7 +168,6 @@ ecma_typedarray_set_int8_element (lit_utf8_byte_t *dst_p, /**< the location in t *dst_p = (lit_utf8_byte_t) num; } /* ecma_typedarray_set_int8_element */ - /** * Write an uint8_t value into the given arraybuffer */ @@ -223,7 +221,6 @@ ecma_typedarray_set_int16_element (lit_utf8_byte_t *dst_p, /**< the location in memcpy (dst_p, &num, sizeof (int16_t)); } /* ecma_typedarray_set_int16_element */ - /** * Write an uint8_t value into the given arraybuffer */ @@ -246,7 +243,6 @@ ecma_typedarray_set_int32_element (lit_utf8_byte_t *dst_p, /**< the location in memcpy (dst_p, &num, sizeof (int32_t)); } /* ecma_typedarray_set_int32_element */ - /** * Write an uint32_t value into the given arraybuffer */ @@ -258,7 +254,6 @@ ecma_typedarray_set_uint32_element (lit_utf8_byte_t *dst_p, /**< the location in memcpy (dst_p, &num, sizeof (uint32_t)); } /* ecma_typedarray_set_uint32_element */ - /** * Write a float value into the given arraybuffer */ @@ -283,7 +278,6 @@ ecma_typedarray_set_double_element (lit_utf8_byte_t *dst_p, /**< the location in } /* ecma_typedarray_set_double_element */ #endif /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */ - /** * Builtin id of the first %TypedArray% builtin routine intrinsic object */ @@ -666,7 +660,6 @@ ecma_typedarray_create_object_with_typedarray (ecma_object_t *typedarray_p, /**< ecma_typedarray_getter_fn_t src_typedarray_getter_cb = ecma_get_typedarray_getter_fn (src_id); ecma_typedarray_setter_fn_t target_typedarray_setter_cb = ecma_get_typedarray_setter_fn (typedarray_id); - for (uint32_t i = 0; i < array_length; i++) { /* Convert values from source to destination format. */ @@ -839,7 +832,6 @@ ecma_typedarray_get_element_size_shift (ecma_object_t *typedarray_p) /**< the po return ecma_typedarray_helper_get_shift_size (ecma_get_typedarray_id (typedarray_p)); } /* ecma_typedarray_get_element_size_shift */ - /** * Get the array length of the typedarray object * diff --git a/jerry-core/include/jerryscript-core.h b/jerry-core/include/jerryscript-core.h index e06dd17f0..79aa01489 100644 --- a/jerry-core/include/jerryscript-core.h +++ b/jerry-core/include/jerryscript-core.h @@ -666,7 +666,6 @@ typedef enum JERRY_TYPEDARRAY_FLOAT64, } jerry_typedarray_type_t; - bool jerry_value_is_typedarray (jerry_value_t value); jerry_value_t jerry_create_typedarray (jerry_typedarray_type_t type_name, jerry_length_t length); jerry_value_t jerry_create_typedarray_for_arraybuffer_sz (jerry_typedarray_type_t type_name, diff --git a/jerry-core/jmem/jmem-allocator.c b/jerry-core/jmem/jmem-allocator.c index e59148031..7357e49de 100644 --- a/jerry-core/jmem/jmem-allocator.c +++ b/jerry-core/jmem/jmem-allocator.c @@ -231,4 +231,3 @@ jmem_decompress_pointer (uintptr_t compressed_pointer) /**< pointer to decompres return (void *) uint_ptr; } /* jmem_decompress_pointer */ - diff --git a/jerry-core/jmem/jmem-heap.c b/jerry-core/jmem/jmem-heap.c index a2b9c9d0f..63d331adb 100644 --- a/jerry-core/jmem/jmem-heap.c +++ b/jerry-core/jmem/jmem-heap.c @@ -409,7 +409,6 @@ jmem_heap_insert_block (jmem_heap_free_t *block_p, /**< block to insert */ JMEM_VALGRIND_DEFINED_SPACE (block_p, sizeof (jmem_heap_free_t)); JMEM_VALGRIND_DEFINED_SPACE (next_p, sizeof (jmem_heap_free_t)); - const uint32_t block_offset = JMEM_HEAP_GET_OFFSET_FROM_ADDR (block_p); /* Update prev. */ diff --git a/jerry-core/lit/lit-magic-strings.inc.h b/jerry-core/lit/lit-magic-strings.inc.h index 4918a0118..29dbc1138 100644 --- a/jerry-core/lit/lit-magic-strings.inc.h +++ b/jerry-core/lit/lit-magic-strings.inc.h @@ -16,7 +16,6 @@ /* This file is automatically generated by the gen-magic-strings.py script * from lit-magic-strings.ini. Do not edit! */ - LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING__EMPTY, "") LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_SPACE_CHAR, " ") #if ENABLED (JERRY_ES2015) diff --git a/jerry-core/parser/js/js-lexer.c b/jerry-core/parser/js/js-lexer.c index 809532673..4739f60bf 100644 --- a/jerry-core/parser/js/js-lexer.c +++ b/jerry-core/parser/js/js-lexer.c @@ -2692,7 +2692,6 @@ lexer_construct_regexp_object (parser_context_t *context_p, /**< context */ pattern_str_p = ecma_new_ecma_string_from_utf8_converted_to_cesu8 (regex_start_p, length); } - completion_value = re_compile_bytecode (&re_bytecode_p, pattern_str_p, current_flags); diff --git a/jerry-core/vm/vm.h b/jerry-core/vm/vm.h index feb1f9931..2d1e9bbfb 100644 --- a/jerry-core/vm/vm.h +++ b/jerry-core/vm/vm.h @@ -1,4 +1,3 @@ - /* Copyright JS Foundation and other contributors, http://js.foundation * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/jerry-ext/arg/arg.c b/jerry-ext/arg/arg.c index 9239106ba..1421b6493 100644 --- a/jerry-ext/arg/arg.c +++ b/jerry-ext/arg/arg.c @@ -17,7 +17,6 @@ #include "jerryscript-ext/arg.h" #include "jerryscript.h" - #define JERRYX_STATIC_ASSERT(x, msg) \ enum { static_assertion_failed_ ## msg = 1 / (!!(x)) } diff --git a/jerry-ext/include/jerryscript-ext/handle-scope.h b/jerry-ext/include/jerryscript-ext/handle-scope.h index bd871fb73..bf403b826 100644 --- a/jerry-ext/include/jerryscript-ext/handle-scope.h +++ b/jerry-ext/include/jerryscript-ext/handle-scope.h @@ -67,7 +67,6 @@ struct jerryx_handle_scope_s JERRYX_HANDLE_SCOPE_FIELDS; /**< common handle scope fields */ }; - typedef struct jerryx_handle_scope_dynamic_s jerryx_handle_scope_dynamic_t; /** * Dynamically allocated handle scope type. diff --git a/jerry-ext/module/module.c b/jerry-ext/module/module.c index 896b7caa9..f246f2f14 100644 --- a/jerry-ext/module/module.c +++ b/jerry-ext/module/module.c @@ -208,7 +208,6 @@ jerryx_module_resolver_t jerryx_module_native_resolver = .resolve_p = jerryx_resolve_native_module }; - static void jerryx_module_resolve_local (const jerry_value_t name, /**< name of the module to load */ const jerryx_module_resolver_t **resolvers_p, /**< list of resolvers */ diff --git a/jerry-libm/jerry-libm-internal.h b/jerry-libm/jerry-libm-internal.h index fb29c7f44..1753e74d4 100644 --- a/jerry-libm/jerry-libm-internal.h +++ b/jerry-libm/jerry-libm-internal.h @@ -30,7 +30,6 @@ /* Sometimes it's necessary to define __LITTLE_ENDIAN explicitly but these catch some common cases. */ - #ifndef __LITTLE_ENDIAN /* Check if compiler has byte order macro. Some older versions do not. * If byte order is supported and set to little or target is among common diff --git a/jerry-libm/sqrt.c b/jerry-libm/sqrt.c index fd45a6f59..182a76ff9 100644 --- a/jerry-libm/sqrt.c +++ b/jerry-libm/sqrt.c @@ -275,7 +275,6 @@ A. sqrt(x) by Newton Iteration ------------------------------------------------------ msb lsb msb lsb ...order - ------------------------ ------------------------ x0: |s| e | f1 | x1: | f2 | ------------------------ ------------------------ @@ -307,7 +306,6 @@ A. sqrt(x) by Newton Iteration y := (y+x/y)/2 ... almost 35 sig. bits y := y-(y-x/y)/2 ... within 1 ulp - Remark 1. Another way to improve y to within 1 ulp is: @@ -320,7 +318,6 @@ A. sqrt(x) by Newton Iteration 2 3y + x - This formula has one division fewer than the one above; however, it requires more multiplications and additions. Also x must be scaled in advance to avoid spurious overflow in evaluating the @@ -367,7 +364,6 @@ A. sqrt(x) by Newton Iteration Square root of +inf, +-0, or NaN is itself; Square root of a negative number is NaN with invalid signal. - B. sqrt(x) by Reciproot Iteration (1) Initial approximation diff --git a/jerry-main/benchmarking.c b/jerry-main/benchmarking.c index 28546566b..d4c1be5c4 100644 --- a/jerry-main/benchmarking.c +++ b/jerry-main/benchmarking.c @@ -50,7 +50,6 @@ int gettimeofday (struct timeval *tv, } /* gettimeofday */ #endif /* __GNUC__ */ - int rand (void); /** diff --git a/jerry-main/libfuzzer.c b/jerry-main/libfuzzer.c index 9b007c589..10de4506b 100644 --- a/jerry-main/libfuzzer.c +++ b/jerry-main/libfuzzer.c @@ -17,7 +17,6 @@ #include "jerryscript.h" - int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size) { srand (0); diff --git a/jerry-main/main-unix.c b/jerry-main/main-unix.c index 733f65cc7..c0c3eb502 100644 --- a/jerry-main/main-unix.c +++ b/jerry-main/main-unix.c @@ -274,7 +274,6 @@ register_js_function (const char *name_p, /**< name of the function */ jerry_release_value (result_val); } /* register_js_function */ - /** * Runs the source code received by jerry_debugger_wait_for_client_source. * @@ -304,7 +303,6 @@ wait_for_source_callback (const jerry_char_t *resource_name_p, /**< resource nam return ret_val; } /* wait_for_source_callback */ - /** * Command line option IDs */ diff --git a/jerry-port/default/default-date.c b/jerry-port/default/default-date.c index f988cc8c9..bd8939d88 100644 --- a/jerry-port/default/default-date.c +++ b/jerry-port/default/default-date.c @@ -41,7 +41,6 @@ void UnixTimeToFileTime (LONGLONG t, LPFILETIME pft) } /* UnixTimeToFileTime */ #endif /* _WINDOWS */ - /** * Default implementation of jerry_port_get_local_time_zone_adjustment. Uses the 'tm_gmtoff' field * of 'struct tm' (a GNU extension) filled by 'localtime_r' if available on the diff --git a/tests/unit-core/test-api-binary-operations-arithmetics.c b/tests/unit-core/test-api-binary-operations-arithmetics.c index a4cde15ef..8401b51ed 100644 --- a/tests/unit-core/test-api-binary-operations-arithmetics.c +++ b/tests/unit-core/test-api-binary-operations-arithmetics.c @@ -40,7 +40,6 @@ typedef struct jerry_value_t expected; } test_entry_t; - typedef struct { jerry_binary_operation_t op; @@ -191,7 +190,6 @@ main (void) T (JERRY_BIN_OP_SUB, jerry_create_boolean (false), jerry_create_boolean (false), jerry_create_number (0.0)), T (JERRY_BIN_OP_SUB, jerry_create_null (), jerry_create_null (), jerry_create_number (-0.0)), - /* Testing multiplication (*) */ T (JERRY_BIN_OP_MUL, jerry_create_number (5.0), jerry_create_number (5.0), jerry_create_number (25.0)), T (JERRY_BIN_OP_MUL, jerry_create_number (3.1), jerry_create_number (10), jerry_create_number (31)), diff --git a/tests/unit-core/test-api.c b/tests/unit-core/test-api.c index 86735229a..48f5ec81a 100644 --- a/tests/unit-core/test-api.c +++ b/tests/unit-core/test-api.c @@ -119,7 +119,6 @@ handler_construct_2_freecb (void *native_p) test_api_is_free_callback_was_called = true; } /* handler_construct_2_freecb */ - /** * The name of the jerry_object_native_info_t struct. */ @@ -271,8 +270,6 @@ foreach (const jerry_value_t name, /**< field name */ TEST_ASSERT (false); return false; - - } /* foreach */ static bool diff --git a/tests/unit-core/test-context-data.c b/tests/unit-core/test-context-data.c index 152211687..d2ef7c574 100644 --- a/tests/unit-core/test-context-data.c +++ b/tests/unit-core/test-context-data.c @@ -113,7 +113,6 @@ test_context_data4_new (void *user_data_p) TEST_ASSERT (user_data_p == NULL); } /* test_context_data4_new */ - static void test_context_data4_free (void *user_data_p) { @@ -138,7 +137,6 @@ static const jerry_context_data_manager_t manager4 = .bytes_needed = 0 }; - int main (void) { diff --git a/tests/unit-core/test-mem-stats.c b/tests/unit-core/test-mem-stats.c index 322eb27cd..2a29ae6ed 100644 --- a/tests/unit-core/test-mem-stats.c +++ b/tests/unit-core/test-mem-stats.c @@ -16,7 +16,6 @@ #include "jerryscript.h" #include "test-common.h" - int main (void) { if (!jerry_is_feature_enabled (JERRY_FEATURE_MEM_STATS)) diff --git a/tests/unit-core/test-native-callback-nested.c b/tests/unit-core/test-native-callback-nested.c index 6207cef7b..0d5b067d7 100644 --- a/tests/unit-core/test-native-callback-nested.c +++ b/tests/unit-core/test-native-callback-nested.c @@ -13,7 +13,6 @@ * limitations under the License. */ - #include "jerryscript.h" #include "jerryscript-port.h" #include "jerryscript-port-default.h" diff --git a/tests/unit-core/test-promise.c b/tests/unit-core/test-promise.c index bd37fc403..2103efea1 100644 --- a/tests/unit-core/test-promise.c +++ b/tests/unit-core/test-promise.c @@ -18,7 +18,6 @@ #include "jerryscript-port-default.h" #include "test-common.h" - static const jerry_char_t test_source[] = TEST_STRING_LITERAL ( "var p1 = create_promise1();" "var p2 = create_promise2();" diff --git a/tests/unit-core/test-resource-name.c b/tests/unit-core/test-resource-name.c index ebbfa4a82..449900e38 100644 --- a/tests/unit-core/test-resource-name.c +++ b/tests/unit-core/test-resource-name.c @@ -100,7 +100,6 @@ main (void) "f2(); \n"); const char *resource_2 = "demo2.js"; - program = jerry_parse ((const jerry_char_t *) resource_2, strlen (resource_2), (const jerry_char_t *) source_2, diff --git a/tests/unit-core/test-stringbuilder.c b/tests/unit-core/test-stringbuilder.c index d993fbdab..7aa4eab30 100644 --- a/tests/unit-core/test-stringbuilder.c +++ b/tests/unit-core/test-stringbuilder.c @@ -155,7 +155,6 @@ main (void) } ecma_string_t *result_p = ecma_stringbuilder_finalize (&builder); - ecma_string_t *expected_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY); for (size_t i = 0; i < count; i++) { diff --git a/tests/unit-core/test-to-integer.c b/tests/unit-core/test-to-integer.c index 37097f2d9..e606b2c16 100644 --- a/tests/unit-core/test-to-integer.c +++ b/tests/unit-core/test-to-integer.c @@ -130,5 +130,3 @@ main (void) return 0; } /* main */ - - diff --git a/tests/unit-ext/test-ext-arg.c b/tests/unit-ext/test-ext-arg.c index 0aabdbd6e..9d0391166 100644 --- a/tests/unit-ext/test-ext-arg.c +++ b/tests/unit-ext/test-ext-arg.c @@ -401,7 +401,6 @@ test_validator_prop2_handler (const jerry_value_t func_obj_val, /**< function ob jerry_value_t is_ok = jerryx_arg_transform_args (args_p, args_cnt, mapping, ARRAY_SIZE (mapping)); - TEST_ASSERT (!jerry_value_is_error (is_ok)); if (validator_prop_count == 1) @@ -622,7 +621,6 @@ test_validator_array1_handler (const jerry_value_t func_obj_val, /**< function o jerry_value_t is_ok = jerryx_arg_transform_args (args_p, args_cnt, mapping, ARRAY_SIZE (mapping)); - TEST_ASSERT (!jerry_value_is_error (is_ok)); if (validator_array_count == 0) diff --git a/tests/unit-ext/test-ext-method-register.c b/tests/unit-ext/test-ext-method-register.c index 30e886f7f..8f6daafa1 100644 --- a/tests/unit-ext/test-ext-method-register.c +++ b/tests/unit-ext/test-ext-method-register.c @@ -185,7 +185,6 @@ test_error_setvalue (void) jerry_cleanup (); } /* test_error_setvalue */ - /** * Test registration error with jerryx_set_properties. * diff --git a/tools/gen-magic-strings.py b/tools/gen-magic-strings.py index 504023f25..06e774aac 100755 --- a/tools/gen-magic-strings.py +++ b/tools/gen-magic-strings.py @@ -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: diff --git a/tools/vera++/profiles/jerry b/tools/vera++/profiles/jerry index 23fa09756..1ffa7a50a 100644 --- a/tools/vera++/profiles/jerry +++ b/tools/vera++/profiles/jerry @@ -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 diff --git a/tools/vera++/scripts/rules/jerry_no_consecutive_empty_lines.tcl b/tools/vera++/scripts/rules/jerry_no_consecutive_empty_lines.tcl new file mode 100644 index 000000000..030ce84ce --- /dev/null +++ b/tools/vera++/scripts/rules/jerry_no_consecutive_empty_lines.tcl @@ -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 + } +} diff --git a/tools/vera++/scripts/rules/jerry_no_leading_or_trailing_empty_line.tcl b/tools/vera++/scripts/rules/jerry_no_leading_or_trailing_empty_line.tcl new file mode 100644 index 000000000..340dad2c2 --- /dev/null +++ b/tools/vera++/scripts/rules/jerry_no_leading_or_trailing_empty_line.tcl @@ -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)" + } + } +}