Skip to content

Commit

Permalink
Issue #14937: Migrated section 3.2 Package Statement to follow chapte…
Browse files Browse the repository at this point in the history
…r wise testing
  • Loading branch information
Zopsss authored and romani committed Jun 19, 2024
1 parent 104cf77 commit b03286a
Show file tree
Hide file tree
Showing 13 changed files with 123 additions and 353 deletions.
5 changes: 5 additions & 0 deletions config/checkstyle-non-main-files-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
<!-- test resources are weird by design, no validations in them -->
<suppress id="lineLength"
files="src[\\/]it[\\/]resources[\\/].*[\\/]InputLineLength.*\.java"/>
<suppress id="lineLength"
files="src[\\/]it[\\/]resources[\\/].*[\\/]InputPackageStatement\.java"/>
<suppress id="lineLength"
files="src[\\/]it[\\/]resources[\\/].*[\\/]InputPackageStatementLongName.*\.java"
lines="1"/>
<suppress id="lineLength"
files="src[\\/]test[\\/]resources[\\/].*[\\/]InputLineLength.*\.java"/>
<suppress id="lineLength"
Expand Down
3 changes: 2 additions & 1 deletion config/jsoref-spellchecker/whitelist.words
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ packageinfo
packagename
packagenamesloader
packageobjectfactory
packagestate
packagestatement
packge
packifc
packpub
Expand Down Expand Up @@ -1333,6 +1333,7 @@ tokennizer
tokentype
tolist
Toolbar
toolongpackagetotestcoveragegooglesjavastylerule
TOSTRING
Touchscreen
trailingcomment
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code and other text files for adherence to a set of rules.
// Copyright (C) 2001-2024 the original author or authors.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
///////////////////////////////////////////////////////////////////////////////////////////////

package com.google.checkstyle.test.chapter3filestructure.rule32packagestatement;

import org.junit.jupiter.api.Test;

import com.google.checkstyle.test.base.AbstractGoogleModuleTestSupport;

public class PackageStatementTest extends AbstractGoogleModuleTestSupport {

@Override
protected String getPackageLocation() {
return "com/google/checkstyle/test/chapter3filestructure/rule32packagestatement";
}

@Test
public void testPackageStatement() throws Exception {
final String filePath = getPath("InputPackageStatement.java");

final String[] listOfModules = {
"LineLength",
"NoLineWrap",
};

verifyWithGoogleConfigParser(listOfModules, filePath);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
///////////////////////////////////////////////////////////////////////////////////////////////

package com.google.checkstyle.test.chapter3filestructure.rule32packagestate;
package com.google.checkstyle.test.chapter3filestructure.rule332nolinewrap;

import org.junit.jupiter.api.Test;

Expand All @@ -29,20 +29,14 @@ public class LineLengthTest extends AbstractGoogleModuleTestSupport {

@Override
protected String getPackageLocation() {
return "com/google/checkstyle/test/chapter3filestructure/rule32packagestate";
return "com/google/checkstyle/test/chapter3filestructure/rule332nolinewrap";
}

@Test
public void testLineLength() throws Exception {
final String[] expected = {
"5: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 112),
"29: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 183),
"46: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 131),
"47: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 124),
"48: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 113),
"50: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 116),
"53: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 131),
"57: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 116),
"7: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 112),
"9: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 113),
};

final Configuration checkConfig = getModuleConfig("LineLength");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public void testGoodLineWrap() throws Exception {
public void goodLineLength() throws Exception {
final int maxLineLength = 100;
final String[] expected = {
"5: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", maxLineLength, 112),
"29: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", maxLineLength, 113),
"7: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", maxLineLength, 112),
"9: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", maxLineLength, 113),
};

final Configuration checkConfig = getModuleConfig("LineLength");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
///////////////////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code and other text files for adherence to a set of rules.
// Copyright (C) 2001-2024 the original author or authors.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
///////////////////////////////////////////////////////////////////////////////////////////////

package com.google.checkstyle.test.chapter3filestructure.toolongpackagetotestcoveragegooglesjavastylerule;

import org.junit.jupiter.api.Test;

import com.google.checkstyle.test.base.AbstractGoogleModuleTestSupport;

public class PackageStatementTest extends AbstractGoogleModuleTestSupport {

@Override
protected String getPackageLocation() {
return "com/google/checkstyle/test/chapter3filestructure/"
+ "toolongpackagetotestcoveragegooglesjavastylerule";
}

@Test
public void testPackageStatement() throws Exception {
final String filePath = getPath("InputPackageStatementLongName.java");

final String[] listOfModules = {
"LineLength",
"NoLineWrap",
};

verifyWithGoogleConfigParser(listOfModules, filePath);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.google.checkstyle.test. // violation 'package statement should not be line-wrapped.'
chapter3filestructure.rule32packagestatement;

public class InputPackageStatement {
// Long line ----------------------------------------------------------------------------------------
// violation above 'Line is longer than 100 characters (found 103).'

private int[] mInts = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
// violation above 'Line is longer than 100 characters (found 174).'
}
Loading

0 comments on commit b03286a

Please sign in to comment.