From 916da443b1e81bfff4c81f8ea2a784ce72338259 Mon Sep 17 00:00:00 2001 From: Ilya Vlasov Date: Tue, 3 Aug 2021 10:41:13 +0300 Subject: [PATCH 1/2] Fixed issue #87 --- src/python/review/inspectors/checkstyle/files/config.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/python/review/inspectors/checkstyle/files/config.xml b/src/python/review/inspectors/checkstyle/files/config.xml index 92fa6f07..81fbc370 100644 --- a/src/python/review/inspectors/checkstyle/files/config.xml +++ b/src/python/review/inspectors/checkstyle/files/config.xml @@ -44,8 +44,9 @@ - - + + + From 8a5928de00a4ad60a580d9fce7a419e774c028a2 Mon Sep 17 00:00:00 2001 From: Ilya Vlasov Date: Tue, 3 Aug 2021 10:41:22 +0300 Subject: [PATCH 2/2] Added test --- .../inspectors/test_checkstyle_inspector.py | 1 + test/python/inspectors/test_pmd_inspector.py | 1 + .../java/test_multiple_literals.java | 32 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 test/resources/inspectors/java/test_multiple_literals.java diff --git a/test/python/inspectors/test_checkstyle_inspector.py b/test/python/inspectors/test_checkstyle_inspector.py index ce7040aa..ac691ff6 100644 --- a/test/python/inspectors/test_checkstyle_inspector.py +++ b/test/python/inspectors/test_checkstyle_inspector.py @@ -43,6 +43,7 @@ ('test_indentation_with_spaces.java', 0), ('test_indentation_with_tabs.java', 0), ('test_indentation_google_style.java', 4), + ('test_multiple_literals.java', 1), ] diff --git a/test/python/inspectors/test_pmd_inspector.py b/test/python/inspectors/test_pmd_inspector.py index 15b8006e..3702a79b 100644 --- a/test/python/inspectors/test_pmd_inspector.py +++ b/test/python/inspectors/test_pmd_inspector.py @@ -32,6 +32,7 @@ ('test_valid_curly_braces.java', 0), ('test_when_only_equals_overridden.java', 1), ('test_valid_spaces.java', 0), + ('test_multiple_literals.java', 1), ] diff --git a/test/resources/inspectors/java/test_multiple_literals.java b/test/resources/inspectors/java/test_multiple_literals.java new file mode 100644 index 00000000..58a9e2ee --- /dev/null +++ b/test/resources/inspectors/java/test_multiple_literals.java @@ -0,0 +1,32 @@ +class Main { + public static void main(String[] args) { + // ok + String shortRareLiteral1 = "12"; + String shortRareLiteral2 = "12"; + String shortRareLiteral3 = "12"; + + // ok + String longRareLiteral1 = "123"; + String longRareLiteral2 = "123"; + String longRareLiteral3 = "123"; + + // ok + String shortFrequentLiteral1 = "34"; + String shortFrequentLiteral2 = "34"; + String shortFrequentLiteral3 = "34"; + String shortFrequentLiteral4 = "34"; + + // warning + String longFrequentLiteral1 = "456"; + String longFrequentLiteral2 = "456"; + String longFrequentLiteral3 = "456"; + String longFrequentLiteral4 = "456"; + + System.out.println( + shortRareLiteral1 + shortRareLiteral2 + shortRareLiteral3 + + longRareLiteral1 + longRareLiteral2 + longRareLiteral3 + + shortFrequentLiteral1 + shortFrequentLiteral2 + shortFrequentLiteral3 + shortFrequentLiteral4 + + longFrequentLiteral1 + longFrequentLiteral2 + longFrequentLiteral3 + longFrequentLiteral4 + ); + } +}