@@ -1510,28 +1510,34 @@ public void testInvalidArrayInitWithTrueStrictCondition()
1510
1510
"22:7: " + getCheckMessage (MSG_ERROR , "member def type" , 6 , 4 ),
1511
1511
"24:3: " + getCheckMessage (MSG_ERROR , "member def type" , 2 , 4 ),
1512
1512
"28:7: " + getCheckMessage (MSG_ERROR , "member def type" , 6 , 4 ),
1513
- "29:9: " + getCheckMessage (MSG_CHILD_ERROR , "array initialization" , 8 , 10 ),
1513
+ "29:9: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 8 ,
1514
+ "10, 34, 36" ),
1514
1515
"30:5: " + getCheckMessage (MSG_ERROR_MULTI , "array initialization rcurly" , 4 , "6, 10" ),
1515
- "33:10: " + getCheckMessage (MSG_CHILD_ERROR , "array initialization" , 9 , 8 ),
1516
- "34:8: " + getCheckMessage (MSG_CHILD_ERROR , "array initialization" , 7 , 8 ),
1517
- "35:10: " + getCheckMessage (MSG_CHILD_ERROR , "array initialization" , 9 , 8 ),
1516
+ "33:10: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 9 ,
1517
+ "8, 31, 33" ),
1518
+ "34:8: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 7 ,
1519
+ "8, 31, 33" ),
1520
+ "35:10: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 9 ,
1521
+ "8, 31, 33" ),
1518
1522
"40:3: " + getCheckMessage (MSG_ERROR_MULTI , "array initialization lcurly" , 2 , "4, 8" ),
1519
1523
"44:7: " + getCheckMessage (MSG_ERROR_MULTI , "array initialization rcurly" , 6 , "4, 8" ),
1520
1524
"48:3: " + getCheckMessage (MSG_ERROR_MULTI , "array initialization lcurly" , 2 , "4, 8" ),
1521
1525
"52:21: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 20 ,
1522
1526
"8, 31, 33" ),
1523
1527
"53:5: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" ,
1524
1528
4 , "8, 31, 33" ),
1525
- "58:7: " + getCheckMessage (MSG_CHILD_ERROR , "array initialization" , 6 , 8 ),
1529
+ "58:7: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" ,
1530
+ 6 , "8, 31, 33" ),
1526
1531
"63:3: " + getCheckMessage (MSG_ERROR , "member def type" , 2 , 4 ),
1527
1532
"65:7: " + getCheckMessage (MSG_ERROR , "member def type" , 6 , 4 ),
1528
1533
"66:3: " + getCheckMessage (MSG_ERROR_MULTI , "array initialization rcurly" , 2 , "6, 10" ),
1529
- "69:7: " + getCheckMessage (MSG_CHILD_ERROR , "array initialization" , 6 , 8 ),
1530
- "76:11: " + getCheckMessage (MSG_CHILD_ERROR , "array initialization" , 10 , 12 ),
1534
+ "69:7: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" ,
1535
+ 6 , "8, 36, 38" ),
1536
+ "76:11: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" ,
1537
+ 10 , "12, 24, 26" ),
1531
1538
};
1532
1539
1533
- // Test input for this test case is not checked due to issue #693.
1534
- verify (checkConfig , fileName , expected );
1540
+ verifyWarns (checkConfig , fileName , expected );
1535
1541
}
1536
1542
1537
1543
@ Test
@@ -1550,29 +1556,184 @@ public void testInvalidArrayInitWithTrueStrictCondition1()
1550
1556
final String fileName = getPath ("InputIndentationInvalidArrayInitIndent1.java" );
1551
1557
final String [] expected = {
1552
1558
"28:9: " + getCheckMessage (MSG_ERROR , "1" , 8 , 12 ),
1553
- "39:11: " + getCheckMessage (MSG_CHILD_ERROR , "array initialization" , 10 , 12 ),
1554
- "40:15: " + getCheckMessage (MSG_CHILD_ERROR , "array initialization" , 14 , 12 ),
1555
- "43:11: " + getCheckMessage (MSG_CHILD_ERROR , "array initialization" , 10 , 12 ),
1556
- "44:15: " + getCheckMessage (MSG_CHILD_ERROR , "array initialization" , 14 , 12 ),
1559
+ "39:11: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 10 ,
1560
+ "12, 30, 32" ),
1561
+ "40:15: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 14 ,
1562
+ "12, 30, 32" ),
1563
+ "43:11: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 10 ,
1564
+ "12, 31, 32" ),
1565
+ "44:15: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 14 ,
1566
+ "12, 31, 32" ),
1557
1567
"45:7: " + getCheckMessage (MSG_ERROR_MULTI , "array initialization rcurly" , 6 , "8, 12" ),
1558
1568
"48:7: " + getCheckMessage (MSG_ERROR_MULTI , "array initialization lcurly" , 6 , "8, 12" ),
1559
- "49:15: " + getCheckMessage (MSG_CHILD_ERROR , "array initialization" , 14 , 12 ),
1560
- "50:11: " + getCheckMessage (MSG_CHILD_ERROR , "array initialization" , 10 , 12 ),
1569
+ "49:15: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 14 ,
1570
+ "8, 10, 12" ),
1571
+ "51:7: " + getCheckMessage (MSG_ERROR_MULTI , "array initialization rcurly" , 6 , "8, 12" ),
1572
+ // following are tests for annotation array initialization
1573
+ "59:13: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "annotation array initialization" ,
1574
+ 12 , "16, 46, 48" ),
1575
+ "67:15: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "annotation array initialization" ,
1576
+ 14 , "16, 28, 30" ),
1577
+ "68:9: " + getCheckMessage (MSG_ERROR_MULTI , "annotation array initialization rcurly" ,
1578
+ 8 , "12, 16" ),
1579
+ "70:13: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "annotation array initialization" ,
1580
+ 12 , "16, 29, 31" ),
1581
+ };
1582
+
1583
+ verifyWarns (checkConfig , fileName , expected );
1584
+ }
1585
+
1586
+ @ Test
1587
+ public void testInvalidArrayInitWithFalseStrictCondition ()
1588
+ throws Exception {
1589
+ final DefaultConfiguration checkConfig = createModuleConfig (IndentationCheck .class );
1590
+
1591
+ checkConfig .addProperty ("arrayInitIndent" , "4" );
1592
+ checkConfig .addProperty ("basicOffset" , "4" );
1593
+ checkConfig .addProperty ("braceAdjustment" , "0" );
1594
+ checkConfig .addProperty ("caseIndent" , "4" );
1595
+ checkConfig .addProperty ("forceStrictCondition" , "false" );
1596
+ checkConfig .addProperty ("lineWrappingIndentation" , "4" );
1597
+ checkConfig .addProperty ("tabWidth" , "4" );
1598
+ checkConfig .addProperty ("throwsIndent" , "4" );
1599
+ final String fileName = getPath ("InputIndentationInvalidArrayInitIndent.java" );
1600
+ final String [] expected = {
1601
+ "21:3: " + getCheckMessage (MSG_ERROR , "member def type" , 2 , 4 ),
1602
+ "22:7: " + getCheckMessage (MSG_ERROR , "member def type" , 6 , 4 ),
1603
+ "24:3: " + getCheckMessage (MSG_ERROR , "member def type" , 2 , 4 ),
1604
+ "28:7: " + getCheckMessage (MSG_ERROR , "member def type" , 6 , 4 ),
1605
+ "29:9: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 8 ,
1606
+ "10, 34, 36" ),
1607
+ "30:5: " + getCheckMessage (MSG_ERROR_MULTI , "array initialization rcurly" , 4 , "6, 10" ),
1608
+ "33:10: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 9 ,
1609
+ "8, 31, 33" ),
1610
+ "34:8: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 7 ,
1611
+ "8, 31, 33" ),
1612
+ "35:10: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 9 ,
1613
+ "8, 31, 33" ),
1614
+ "40:3: " + getCheckMessage (MSG_ERROR_MULTI , "array initialization lcurly" , 2 , "4, 8" ),
1615
+ "44:7: " + getCheckMessage (MSG_ERROR_MULTI , "array initialization rcurly" , 6 , "4, 8" ),
1616
+ "48:3: " + getCheckMessage (MSG_ERROR_MULTI , "array initialization lcurly" , 2 , "4, 8" ),
1617
+ "52:21: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 20 ,
1618
+ "8, 31, 33" ),
1619
+ "53:5: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" ,
1620
+ 4 , "8, 31, 33" ),
1621
+ "58:7: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" ,
1622
+ 6 , "8, 31, 33" ),
1623
+ "63:3: " + getCheckMessage (MSG_ERROR , "member def type" , 2 , 4 ),
1624
+ "65:7: " + getCheckMessage (MSG_ERROR , "member def type" , 6 , 4 ),
1625
+ "66:3: " + getCheckMessage (MSG_ERROR_MULTI , "array initialization rcurly" , 2 , "6, 10" ),
1626
+ "69:7: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" ,
1627
+ 6 , "8, 36, 38" ),
1628
+ "76:11: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" ,
1629
+ 10 , "12, 24, 26" ),
1630
+ };
1631
+
1632
+ verifyWarns (checkConfig , fileName , expected );
1633
+ }
1634
+
1635
+ @ Test
1636
+ public void testInvalidArrayInitWithFalseStrictCondition1 ()
1637
+ throws Exception {
1638
+ final DefaultConfiguration checkConfig = createModuleConfig (IndentationCheck .class );
1639
+
1640
+ checkConfig .addProperty ("arrayInitIndent" , "4" );
1641
+ checkConfig .addProperty ("basicOffset" , "4" );
1642
+ checkConfig .addProperty ("braceAdjustment" , "0" );
1643
+ checkConfig .addProperty ("caseIndent" , "4" );
1644
+ checkConfig .addProperty ("forceStrictCondition" , "false" );
1645
+ checkConfig .addProperty ("lineWrappingIndentation" , "4" );
1646
+ checkConfig .addProperty ("tabWidth" , "4" );
1647
+ checkConfig .addProperty ("throwsIndent" , "4" );
1648
+ final String fileName = getPath ("InputIndentationInvalidArrayInitIndent1.java" );
1649
+ final String [] expected = {
1650
+ "28:9: " + getCheckMessage (MSG_ERROR , "1" , 8 , 12 ),
1651
+ "39:11: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 10 ,
1652
+ "12, 30, 32" ),
1653
+ "40:15: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 14 ,
1654
+ "12, 30, 32" ),
1655
+ "43:11: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 10 ,
1656
+ "12, 31, 32" ),
1657
+ "44:15: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 14 ,
1658
+ "12, 31, 32" ),
1659
+ "45:7: " + getCheckMessage (MSG_ERROR_MULTI , "array initialization rcurly" , 6 , "8, 12" ),
1660
+ "48:7: " + getCheckMessage (MSG_ERROR_MULTI , "array initialization lcurly" , 6 , "8, 12" ),
1661
+ "49:15: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "array initialization" , 14 ,
1662
+ "8, 10, 12" ),
1561
1663
"51:7: " + getCheckMessage (MSG_ERROR_MULTI , "array initialization rcurly" , 6 , "8, 12" ),
1562
1664
// following are tests for annotation array initialization
1563
1665
"59:13: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "annotation array initialization" ,
1564
1666
12 , "16, 46, 48" ),
1565
- "63:15: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "annotation array initialization" ,
1566
- 14 , "12, 16" ),
1567
1667
"67:15: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "annotation array initialization" ,
1568
1668
14 , "16, 28, 30" ),
1569
1669
"68:9: " + getCheckMessage (MSG_ERROR_MULTI , "annotation array initialization rcurly" ,
1570
1670
8 , "12, 16" ),
1571
- "70:13: " + getCheckMessage (MSG_CHILD_ERROR , "annotation array initialization" ,
1671
+ "70:13: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "annotation array initialization" ,
1672
+ 12 , "16, 29, 31" ),
1673
+ };
1674
+
1675
+ verifyWarns (checkConfig , fileName , expected );
1676
+ }
1677
+
1678
+ // Test Input without trailing comment and usage of 'verify' method is due to #16906
1679
+ @ Test
1680
+ public void testInvalidArrayInitIndentNoCommentsTrueStrictCondition ()
1681
+ throws Exception {
1682
+ final DefaultConfiguration checkConfig = createModuleConfig (IndentationCheck .class );
1683
+
1684
+ checkConfig .addProperty ("arrayInitIndent" , "4" );
1685
+ checkConfig .addProperty ("basicOffset" , "4" );
1686
+ checkConfig .addProperty ("braceAdjustment" , "0" );
1687
+ checkConfig .addProperty ("caseIndent" , "4" );
1688
+ checkConfig .addProperty ("forceStrictCondition" , "true" );
1689
+ checkConfig .addProperty ("lineWrappingIndentation" , "4" );
1690
+ checkConfig .addProperty ("tabWidth" , "4" );
1691
+ checkConfig .addProperty ("throwsIndent" , "4" );
1692
+ final String fileName = getPath (
1693
+ "InputIndentationInvalidArrayInitIndentWithoutTrailingComments.java" );
1694
+ final String [] expected = {
1695
+ "28:13: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "annotation array initialization" ,
1696
+ 12 , "16, 46, 48" ),
1697
+ "32:15: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "annotation array initialization" ,
1698
+ 14 , "12, 16" ),
1699
+ "36:15: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "annotation array initialization" ,
1700
+ 14 , "16, 28, 30" ),
1701
+ "37:9: " + getCheckMessage (MSG_ERROR_MULTI , "annotation array initialization rcurly" ,
1702
+ 8 , "12, 16" ),
1703
+ "39:13: " + getCheckMessage (MSG_CHILD_ERROR , "annotation array initialization" ,
1572
1704
12 , 16 ),
1573
1705
};
1706
+ verify (checkConfig , fileName , expected );
1707
+ }
1574
1708
1575
- // Test input for this test case is not checked due to issue #693.
1709
+ // Test Input without trailing comment and usage of 'verify' method is due to #16906
1710
+ @ Test
1711
+ public void testInvalidArrayInitIndentNoCommentsFalseStrictCondition ()
1712
+ throws Exception {
1713
+ final DefaultConfiguration checkConfig = createModuleConfig (IndentationCheck .class );
1714
+
1715
+ checkConfig .addProperty ("arrayInitIndent" , "4" );
1716
+ checkConfig .addProperty ("basicOffset" , "4" );
1717
+ checkConfig .addProperty ("braceAdjustment" , "0" );
1718
+ checkConfig .addProperty ("caseIndent" , "4" );
1719
+ checkConfig .addProperty ("forceStrictCondition" , "false" );
1720
+ checkConfig .addProperty ("lineWrappingIndentation" , "4" );
1721
+ checkConfig .addProperty ("tabWidth" , "4" );
1722
+ checkConfig .addProperty ("throwsIndent" , "4" );
1723
+ final String fileName = getPath (
1724
+ "InputIndentationInvalidArrayInitIndentWithoutTrailingComments.java" );
1725
+ final String [] expected = {
1726
+ "28:13: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "annotation array initialization" ,
1727
+ 12 , "16, 46, 48" ),
1728
+ "32:15: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "annotation array initialization" ,
1729
+ 14 , "12, 16" ),
1730
+ "36:15: " + getCheckMessage (MSG_CHILD_ERROR_MULTI , "annotation array initialization" ,
1731
+ 14 , "16, 28, 30" ),
1732
+ "37:9: " + getCheckMessage (MSG_ERROR_MULTI , "annotation array initialization rcurly" ,
1733
+ 8 , "12, 16" ),
1734
+ "39:13: " + getCheckMessage (MSG_CHILD_ERROR , "annotation array initialization" ,
1735
+ 12 , 16 ),
1736
+ };
1576
1737
verify (checkConfig , fileName , expected );
1577
1738
}
1578
1739
0 commit comments