From 5938774eb3636503fa787f300725483d72096400 Mon Sep 17 00:00:00 2001 From: jiangkaiwen Date: Thu, 9 Feb 2023 15:27:54 +0800 Subject: [PATCH] Fix codecheck warnings of the master branch 1.Use "%" instead of "+" to complete string operation 2.Delete redundant code 3.Variable types are consistent within the scope Issue:I6DZA5 Signed-off-by: jiangkaiwen Change-Id: I3f4af94df31443ed613259a9b5eb555f18b10da2 --- .../ir/expressions/literals/regExpLiteral.cpp | 1 - es2panda/parser/expressionParser.cpp | 1 - es2panda/scripts/gen_isa.sh | 2 +- es2panda/scripts/gen_keywords.sh | 2 +- es2panda/test/runner.py | 15 +++++++-------- es2panda/util/base64.cpp | 5 ++++- test262/run_sunspider.py | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/es2panda/ir/expressions/literals/regExpLiteral.cpp b/es2panda/ir/expressions/literals/regExpLiteral.cpp index b87cd4ab3d1..f20ab4c5343 100644 --- a/es2panda/ir/expressions/literals/regExpLiteral.cpp +++ b/es2panda/ir/expressions/literals/regExpLiteral.cpp @@ -56,7 +56,6 @@ void RegExpLiteral::Compile(compiler::PandaGen *pg) const checker::Type *RegExpLiteral::Check(checker::Checker *checker) const { - // TODO(aszilagyi); return checker->GlobalAnyType(); } diff --git a/es2panda/parser/expressionParser.cpp b/es2panda/parser/expressionParser.cpp index f1bb14994b7..9fb0e7cea75 100644 --- a/es2panda/parser/expressionParser.cpp +++ b/es2panda/parser/expressionParser.cpp @@ -629,7 +629,6 @@ ir::Expression *ParserImpl::ParseCoverParenthesizedExpressionAndArrowParameterLi if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_ARROW) { lexer_->Rewind(startPos); return expr; - // ThrowSyntaxError("'=>' expected."); } return ParseArrowFunctionExpression(expr, nullptr, returnTypeAnnotation, false); diff --git a/es2panda/scripts/gen_isa.sh b/es2panda/scripts/gen_isa.sh index 28ab703f1b0..28a7938f7dd 100755 --- a/es2panda/scripts/gen_isa.sh +++ b/es2panda/scripts/gen_isa.sh @@ -45,7 +45,7 @@ do esac done -if [ ! -d ${OUTDIR} ]; then +if [ ! -d "${OUTDIR}" ]; then mkdir -p ${OUTDIR} fi echo "${GENERATOR} --template ${TEMPLATE} --data ${DATA} --output ${OUTDIR}/${OUTPUT} --require ${REQUIRE}" diff --git a/es2panda/scripts/gen_keywords.sh b/es2panda/scripts/gen_keywords.sh index 43f4069f464..5fd915a4466 100755 --- a/es2panda/scripts/gen_keywords.sh +++ b/es2panda/scripts/gen_keywords.sh @@ -39,7 +39,7 @@ do esac done -if [ ! -d ${OUTDIR} ]; then +if [ ! -d "${OUTDIR}" ]; then mkdir -p ${OUTDIR} fi diff --git a/es2panda/test/runner.py b/es2panda/test/runner.py index d63d4384384..94941315e8d 100755 --- a/es2panda/test/runner.py +++ b/es2panda/test/runner.py @@ -228,7 +228,7 @@ class Test262Test(Test): cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=runner.cmd_env) try: - out, err = process.communicate(runner.args.es2panda_timeout) + output_res, err = process.communicate(runner.args.es2panda_timeout) except subprocess.TimeoutExpired: process.kill() self.passed = False @@ -236,7 +236,7 @@ class Test262Test(Test): self.error = self.fail_kind.name return self - out = out.decode("utf-8", errors="ignore") + out = output_res.decode("utf-8", errors="ignore") err = err.decode("utf-8", errors="ignore") self.passed, need_exec = runner.util.validate_parse_result( process.returncode, err, desc, out) @@ -748,8 +748,6 @@ class TSCRunner(Runner): files = glob(glob_expression, recursive=True) files = fnmatch.filter(files, ts_suite_dir + '**' + self.args.filter) - failed_references = open(path.join(self.test_root, 'test_tsc_ignore_list.txt'), 'r').read() - for f in files: test_name = path.basename(f.split(".ts")[0]) negative_references = path.join( @@ -769,9 +767,10 @@ class TSCRunner(Runner): if is_negative or "filename" in test.options: continue - if self.args.skip: - if path.relpath(f, self.tsc_path) in failed_references: - continue + with open(path.join(self.test_root, 'test_tsc_ignore_list.txt'), 'r') as failed_references: + if self.args.skip: + if path.relpath(f, self.tsc_path) in failed_references.read(): + continue self.tests.append(test) @@ -878,7 +877,7 @@ class CompilerProjectTest(Test): test_abc_path = path.join(file_absolute_path, test_abc_name) es2abc_cmd = runner.cmd_prefix + [runner.es2panda] es2abc_cmd.extend(self.flags) - es2abc_cmd.extend(["--output=" + test_abc_path]) + es2abc_cmd.extend(['%s%s' % ("--output=", test_abc_path)]) es2abc_cmd.append(self.path) self.log_cmd(es2abc_cmd) diff --git a/es2panda/util/base64.cpp b/es2panda/util/base64.cpp index 2e691df2348..d727917242d 100644 --- a/es2panda/util/base64.cpp +++ b/es2panda/util/base64.cpp @@ -77,7 +77,10 @@ std::string Base64Decode(const std::string &base64String) decodedStrLen -= std::string("=").length(); } std::string decodedRes = std::string(decodedStrLen, '\0'); - int firstChar, secondChar, thirdChar, fourthChar = 0; + int firstChar = 0; + int secondChar = 0; + int thirdChar = 0; + int fourthChar = 0; for (size_t i = 0, j = 0; i < strLen - 2; i += TRANSFORMED_CHAR_NUM, j += TO_TRANSFORM_CHAR_NUM) { firstChar = decodeTable[static_cast(base64String[i])]; secondChar = decodeTable[static_cast(base64String[i + 1])]; diff --git a/test262/run_sunspider.py b/test262/run_sunspider.py index d3acda909b1..6837ac617bf 100755 --- a/test262/run_sunspider.py +++ b/test262/run_sunspider.py @@ -129,7 +129,7 @@ def exec_command(cmd_args, timeout=DEFAULT_TIMEOUT): code_format = 'gbk' try: - (msg, errs) = proc.communicate(timeout=timeout) + (output_res, errs) = proc.communicate(timeout=timeout) ret_code = proc.poll() if errs.decode(code_format, 'ignore') != '': @@ -142,7 +142,7 @@ def exec_command(cmd_args, timeout=DEFAULT_TIMEOUT): msg += f"error: {str(errs.decode(code_format,'ignore'))}" else: code = 0 - msg = str(msg.decode(code_format, 'ignore')) + msg = str(output_res.decode(code_format, 'ignore')) except subprocess.TimeoutExpired: proc.kill() -- Gitee