Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 38106200D26 for ; Fri, 20 Oct 2017 22:07:12 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 36971160BCB; Fri, 20 Oct 2017 20:07:12 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 545A31609ED for ; Fri, 20 Oct 2017 22:07:11 +0200 (CEST) Received: (qmail 65108 invoked by uid 500); 20 Oct 2017 20:07:05 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 65097 invoked by uid 99); 20 Oct 2017 20:07:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Oct 2017 20:07:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id A57DF1A1220 for ; Fri, 20 Oct 2017 20:07:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.001 X-Spam-Level: X-Spam-Status: No, score=-100.001 tagged_above=-999 required=6.31 tests=[KAM_SHORT=0.001, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id uB_lMEVyRWIl for ; Fri, 20 Oct 2017 20:07:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 2E7855FE3D for ; Fri, 20 Oct 2017 20:07:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 783FBE0B21 for ; Fri, 20 Oct 2017 20:07:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 309C321EEB for ; Fri, 20 Oct 2017 20:07:00 +0000 (UTC) Date: Fri, 20 Oct 2017 20:07:00 +0000 (UTC) From: "Jeff Jirsa (JIRA)" To: commits@cassandra.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CASSANDRA-13799) Fix some alerts raised by lgtm.com MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 20 Oct 2017 20:07:12 -0000 [ https://issues.apache.org/jira/browse/CASSANDRA-13799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16213153#comment-16213153 ] Jeff Jirsa commented on CASSANDRA-13799: ---------------------------------------- Thanks for the follow-up [~malcolmt] ! That looks like an appropriate fix. There's also some unit tests (e.g. {{OperationFctsTest}} ) that rely on the old, incorrect logged strings. For that, I've made these changes, if you're ok with them: {code} diff --git a/test/unit/org/apache/cassandra/cql3/functions/OperationFctsTest.java b/test/unit/org/apache/cassandra/cql3/functions/OperationFctsTest.java index 49c9e30..d27b746 100644 --- a/test/unit/org/apache/cassandra/cql3/functions/OperationFctsTest.java +++ b/test/unit/org/apache/cassandra/cql3/functions/OperationFctsTest.java @@ -292,17 +292,17 @@ public class OperationFctsTest extends CQLTester row(2, (byte) 2, (short) 2, "test")); // tinyint, smallint and int could be used there so we need to disambiguate - assertInvalidMessage("Ambiguous '+' operation: use type casts to disambiguate", + assertInvalidMessage("Ambiguous '+' operation with args ? and 1: use type casts to disambiguate", "SELECT * FROM %s WHERE pk = ? + 1 AND c1 = 2", 1); - assertInvalidMessage("Ambiguous '+' operation: use type casts to disambiguate", + assertInvalidMessage("Ambiguous '+' operation with args ? and 1: use type casts to disambiguate", "SELECT * FROM %s WHERE pk = 2 AND c1 = 2 AND c2 = 1 * (? + 1)", 1); assertRows(execute("SELECT 1 + 1, v FROM %s WHERE pk = 2 AND c1 = 2"), row(2, "test")); // As the output type is unknown the ? type cannot be determined - assertInvalidMessage("Ambiguous '+' operation: use type casts to disambiguate", + assertInvalidMessage("Ambiguous '+' operation with args 1 and ?: use type casts to disambiguate", "SELECT 1 + ?, v FROM %s WHERE pk = 2 AND c1 = 2", 1); // As the prefered type for the constants is int, the returned type will be int @@ -310,7 +310,7 @@ public class OperationFctsTest extends CQLTester row(150, "test")); // As the output type is unknown the ? type cannot be determined - assertInvalidMessage("Ambiguous '+' operation: use type casts to disambiguate", + assertInvalidMessage("Ambiguous '+' operation with args ? and 50: use type casts to disambiguate", "SELECT ? + 50, v FROM %s WHERE pk = 2 AND c1 = 2", 100); createTable("CREATE TABLE %s (a tinyint, b smallint, c int, d bigint, e float, f double, g varint, h decimal, PRIMARY KEY(a, b))" @@ -672,7 +672,7 @@ public class OperationFctsTest extends CQLTester public void testWithNanAndInfinity() throws Throwable { createTable("CREATE TABLE %s (a int PRIMARY KEY, b double, c decimal)"); - assertInvalidMessage("Ambiguous '+' operation: use type casts to disambiguate", + assertInvalidMessage("Ambiguous '+' operation with args ? and 1: use type casts to disambiguate", "INSERT INTO %S (a, b, c) VALUES (? + 1, ?, ?)", 0, Double.NaN, BigDecimal.valueOf(1)); execute("INSERT INTO %S (a, b, c) VALUES ((int) ? + 1, -?, ?)", 0, Double.NaN, BigDecimal.valueOf(1));{code} And: {code} diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java index da5c3bd..a0ae214 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java @@ -2038,13 +2038,13 @@ public class InsertUpdateIfConditionTest extends CQLTester { createTable(" CREATE TABLE %s (k int PRIMARY KEY, v int, d duration)"); - assertInvalidMessage("Slice conditions are not supported on durations", + assertInvalidMessage("Slice conditions ( > ) are not supported on durations", "UPDATE %s SET v = 3 WHERE k = 0 IF d > 1s"); - assertInvalidMessage("Slice conditions are not supported on durations", + assertInvalidMessage("Slice conditions ( >= ) are not supported on durations", "UPDATE %s SET v = 3 WHERE k = 0 IF d >= 1s"); - assertInvalidMessage("Slice conditions are not supported on durations", + assertInvalidMessage("Slice conditions ( <= ) are not supported on durations", "UPDATE %s SET v = 3 WHERE k = 0 IF d <= 1s"); - assertInvalidMessage("Slice conditions are not supported on durations", + assertInvalidMessage("Slice conditions ( < ) are not supported on durations", "UPDATE %s SET v = 3 WHERE k = 0 IF d < 1s"); execute("INSERT INTO %s (k, v, d) VALUES (1, 1, 2s)"); @@ -2100,13 +2100,13 @@ public class InsertUpdateIfConditionTest extends CQLTester assertRows(execute("SELECT * FROM %s WHERE k = 1"), row(1, list(Duration.from("5s"), Duration.from("10s")), 6)); - assertInvalidMessage("Slice conditions are not supported on durations", + assertInvalidMessage("Slice conditions ( > ) are not supported on durations", "UPDATE %s SET v = 3 WHERE k = 0 IF l[0] > 1s"); - assertInvalidMessage("Slice conditions are not supported on durations", + assertInvalidMessage("Slice conditions ( >= ) are not supported on durations", "UPDATE %s SET v = 3 WHERE k = 0 IF l[0] >= 1s"); - assertInvalidMessage("Slice conditions are not supported on durations", + assertInvalidMessage("Slice conditions ( <= ) are not supported on durations", "UPDATE %s SET v = 3 WHERE k = 0 IF l[0] <= 1s"); - assertInvalidMessage("Slice conditions are not supported on durations", + assertInvalidMessage("Slice conditions ( < ) are not supported on durations", "UPDATE %s SET v = 3 WHERE k = 0 IF l[0] < 1s"); assertRows(execute("UPDATE %s SET v = 4 WHERE k = 1 IF l[0] = 2s"), row(false, list(Duration.from("5s"), Duration.from("10s")))); @@ -2218,13 +2218,13 @@ public class InsertUpdateIfConditionTest extends CQLTester assertRows(execute("SELECT * FROM %s WHERE k = 1"), row(1, map(1, Duration.from("5s"), 2, Duration.from("10s")), 6)); - assertInvalidMessage("Slice conditions are not supported on durations", + assertInvalidMessage("Slice conditions ( > ) are not supported on durations", "UPDATE %s SET v = 3 WHERE k = 0 IF m[1] > 1s"); - assertInvalidMessage("Slice conditions are not supported on durations", + assertInvalidMessage("Slice conditions ( >= ) are not supported on durations", "UPDATE %s SET v = 3 WHERE k = 0 IF m[1] >= 1s"); - assertInvalidMessage("Slice conditions are not supported on durations", + assertInvalidMessage("Slice conditions ( <= ) are not supported on durations", "UPDATE %s SET v = 3 WHERE k = 0 IF m[1] <= 1s"); - assertInvalidMessage("Slice conditions are not supported on durations", + assertInvalidMessage("Slice conditions ( < ) are not supported on durations", "UPDATE %s SET v = 3 WHERE k = 0 IF m[1] < 1s"); assertRows(execute("UPDATE %s SET v = 4 WHERE k = 1 IF m[1] = 2s"), row(false, map(1, Duration.from("5s"), 2, Duration.from("10s")))); @@ -2338,13 +2338,13 @@ public class InsertUpdateIfConditionTest extends CQLTester assertRows(execute("SELECT * FROM %s WHERE k = 1"), row(1, userType("i", 1, "d", Duration.from("10s")), 6)); - assertInvalidMessage("Slice conditions are not supported on durations", + assertInvalidMessage("Slice conditions ( > ) are not supported on durations", "UPDATE %s SET v = 3 WHERE k = 0 IF u.d > 1s"); - assertInvalidMessage("Slice conditions are not supported on durations", + assertInvalidMessage("Slice conditions ( >= ) are not supported on durations", "UPDATE %s SET v = 3 WHERE k = 0 IF u.d >= 1s"); - assertInvalidMessage("Slice conditions are not supported on durations", + assertInvalidMessage("Slice conditions ( <= ) are not supported on durations", "UPDATE %s SET v = 3 WHERE k = 0 IF u.d <= 1s"); - assertInvalidMessage("Slice conditions are not supported on durations", + assertInvalidMessage("Slice conditions ( < ) are not supported on durations", "UPDATE %s SET v = 3 WHERE k = 0 IF u.d < 1s"); assertRows(execute("UPDATE %s SET v = 4 WHERE k = 1 IF u.d = 2s"), row(false, userType("i", 1, "d", Duration.from("10s")))); {code} > Fix some alerts raised by lgtm.com > ---------------------------------- > > Key: CASSANDRA-13799 > URL: https://issues.apache.org/jira/browse/CASSANDRA-13799 > Project: Cassandra > Issue Type: Improvement > Reporter: Malcolm Taylor > Assignee: Malcolm Taylor > Fix For: 4.x > > Attachments: 13799-trunk.txt > > > lgtm.com has identified a number of issues where there may be scope for improving the code ([https://lgtm.com/projects/g/apache/cassandra/alerts/?mode=tree&severity=error]). This issue is to address some of the more straightforward cases. -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org For additional commands, e-mail: commits-help@cassandra.apache.org