Commit Graph

4495 Commits

Author SHA1 Message Date
Ilja Dubinin bf3e77cc87 Local variables should not shadow class fields. Issue #46 2015-08-19 06:45:56 +03:00
Andrei Selkin f2efe4d020 Updated comments for excludes of linkcheck, issue #751 2015-08-19 06:44:43 +03:00
Michal Kordas f6b33ebf17 Mark methods as static. #1555
Fixes `MethodMayBeStatic` inspection violations in test code introduced after recent commits.

Description:
>Reports any methods which may safely be made static. A method may be static if it is not synchronized, it does not reference any of its class' non static methods and non static fields and is not overridden in a sub class.
2015-08-19 06:43:05 +03:00
Michal Kordas 9fbba0b380 Add missing @Override annotations in test code. #1555
Fixes `MissingOverrideAnnotation` inspection violations in test code.

Description:
>Reports any methods which override methods in a superclass but do not have the @java.lang.Override annotation.
This inspection only reports if the project or module is configured to use a language level of 5.0 or higher.
2015-08-19 06:41:58 +03:00
Michal Kordas 71b78a97aa Fix incorrect message format parameter. #1555
Fixes ` UnusedMessageFormatParameter` inspection violation introduced in #1648.

Description:
>This inspection reports properties values which looks like java.text.MessageFormat format strings but do not use some of the parameters of {xx} kind.
For example:
```
# parameter {0} is not used
error.message=Something happened in line {1}
```
2015-08-19 06:39:00 +03:00
Michal Kordas bbe93aec4f Replace Arrays.asList() with Collections.emptyList(). #1555
Fixes `ArraysAsListWithZeroOrOneArgument` inspection violations in test code.

Description:
>Reports any calls to Arrays.asList() with zero arguments or only one argument. Such calls could be replaced with either a call to Collections.singletonList() or Collections.emptyList() which will save some memory.
2015-08-19 06:37:53 +03:00
Michal Kordas c5c3b7eed3 Decrease visibility of inner classes. #1555
Possibility to instantiate private checks was added.

Fixes `PublicInnerClass` inspection violation.

Description:
>Reports public inner classes.
2015-08-19 06:35:44 +03:00
Michal Kordas fbc44f14b8 Fix suspicious getters and setters in IndentationCheck. #1555
Fixes `SuspiciousGetterSetter` inspection violations in IndentationCheck.

Description:
>Reports suspicious getter or setter methods. A getter or setter is suspicious if it accesses a different field than would be expected by its name.
2015-08-19 06:32:41 +03:00
Michal Kordas bc0bf95dae Fix non-static non-final all upper-case names in test code. #1555
Fixes `UpperCaseFieldNameNotConstant` inspection violations in test code.

Description:
>Reports non-static non-final fields whose names are all upper-case. Such fields may cause confusion by breaking a common naming convention, and are often the result of developer error.
2015-08-19 06:31:31 +03:00
Michal Kordas 0678968078 Fix questionable names in test code. #1555
Fixes `QuestionableName` inspection violations in test code.

Description:
>Reports on any variables, methods, or classes with questionable names. This inspection is best used to report common metasyntactic variables which may be used as names by lazy or confused developers.
2015-08-19 06:30:04 +03:00
Michal Kordas 88edaa84fd Remove unnecessary explicit numeric cast. #1555
Fixes `UnnecessaryExplicitNumericCast` inspection violations in test code.

Description:
>Reports any primitive numeric casts which would otherwise be inserted implicitly by the compiler.
2015-08-19 06:29:14 +03:00
Michal Kordas 35deee1297 Remove unused field. #1555
Fixes ` FieldCanBeLocal` inspection violation.

Description:
>This inspection searches for redundant class fields that can be replaced with local variables. If all local usages of a field are preceded by assignments to that field, the field can be removed and its usages replaced with local variables.
2015-08-19 06:28:19 +03:00
Michal Kordas f88f22e0ab Remove redundant suppressions from test code. #1555
Fixes `RedundantSuppression` inspection violations in test code.

Description:
>This inspection reports usages of
@SuppressWarning annotation, or
// noinspection line comment, or
/** noinspection */ JavaDoc comment
which can be safely removed because inspection they affect is no longer applicable in this context.
2015-08-19 06:26:49 +03:00
Michal Kordas 3440ef73c9 Replace assertEquals() with arrayAssertEquals(). #1555
Fixes `AssertEqualsCalledOnArray` inspection violations in test code.

Description:
>Reports any calls to JUnit's assertEquals() method with arguments of type array. Arrays should be checked with one of the assertArrayEquals() methods.
2015-08-19 06:25:06 +03:00
Michal Kordas 5306bb6be9 Remove unnecessary @inheritDoc. #1555
Fixes `UnnecessaryInheritDoc` inspection violations in test code.

Description:
>Reports any Javadoc comments which contain only the {@inheritDoc} tag. Since Javadoc copies the super class' comment if no comment is present, a comment containing only an {@inheritDoc} adds nothing.
2015-08-19 06:24:17 +03:00
Michal Kordas 1d7ef7f008 Replace <code> tags with {@code ...} constructs. #1555
Fixes `HtmlTagCanBeJavadocTag` inspection violations in test code.

Description:
>Reports use of <code> tags in Javadoc comments. Since JDK1.5 these constructs may be replaced with {@code ...} constructs. This allows the use of angle brackets (<, >) inside the comment, instead of HTML character entities.
2015-08-19 06:23:36 +03:00
Baratali Izmailov cf9cbc3dca Issue #1243: SuppressWarnings(deprecated) has been removed 2015-08-18 22:43:58 +03:00
Baratali Izmailov 54ccca1863 Issue #1566: First sentence in a comment should start with a capital letter 2015-08-18 04:25:29 -04:00
Andrei Selkin ae73562255 Created JaCoCo profile of pom.xml, issue #1173 2015-08-18 09:40:22 +03:00
Andrei Selkin d71032a054 Provided UTs for valueOf() and values() methods of enums, issue #1173 2015-08-18 09:40:22 +03:00
Andrei Selkin ef58cc5a0d Workaround problem of interoperability between PowerMock and JaCoCo, issue #1173 2015-08-18 09:40:22 +03:00
Michal Kordas aeb68b7da9 Remove unnecessary this in test code. #1555
Fixes `UnnecessaryThis` inspection violations in test code.

Description:
>Reports on any unnecessary uses of this in the code. Using this to disambiguate a code reference may easily become unnecessary via automatic refactorings, and is discouraged by many coding styles.
2015-08-18 08:52:03 +03:00
Michal Kordas 1634b49d11 Create constants out of fields in test code. #1555
Fixes `FieldCanBeLocal` inspection violation in test code.

Description:
>This inspection searches for redundant class fields that can be replaced with local variables. If all local usages of a field are preceded by assignments to that field, the field can be removed and its usages replaced with local variables.
2015-08-18 08:51:06 +03:00
Michal Kordas b062024229 Mark util class as final in test code. #1555
Fixes `ClassWithOnlyPrivateConstructors` inspection violation in test code.

Description:
>Reports classes with only private constructors that are not extended by any nested class. Such classes can not be extended and should be declared final.
2015-08-18 08:50:00 +03:00
Michal Kordas a3fdd52b45 Promote anonymous class to nested class. #1555
Fixes `AnonymousClassMethodCount` inspection violation in test code.

Description:
>Reports anonymous inner class with too many methods. Anonymous classes with more than a very low number of methods may be difficult to understand, and should probably be promoted to become named inner classes.
2015-08-18 08:48:59 +03:00
Michal Kordas 06863d123f Remove nested assignment. #1555
Fixes `NestedAssignment` inspection violation in test code.

Description:
>Reports assignment expressions nested inside other expressions. While admirably terse, such expressions may be confusing, and violate the general design principle that a given construct should do precisely one thing.
2015-08-18 08:47:16 +03:00
Baratali Izmailov b02dba99c5 Issue #1566: File length of JavadocMethodCheck has been reduced 2015-08-18 08:46:12 +03:00
Ilja Dubinin f17f1410a5 Floating point numbers should not be tested for equality. Issue #46 2015-08-18 07:39:59 +03:00
Michal Kordas 8a276f35fd Simplify JUnit assertions. #1555
Fixes `SimplifiableJUnitAssertion` inspection violation in test code.

Description:
>Reports any JUnit assertTrue calls which can be replaced by equivalent assertEquals calls. assertEquals calls will normally give better error messages in case of test failure than assertTrue can.
2015-08-18 07:37:59 +03:00
Michal Kordas 15c91c8ec2 Add missing toString() methods. #1555
Fixes `ObjectToString` inspection violations.

Description:
>Reports any calls to .toString() which use the default implementation from java.lang.Object. The default implementation is rarely desired, but easy to use by accident. Calls to .toString() on objects of type java.lang.Object are ignored by this inspection.
2015-08-18 07:33:59 +03:00
Roman Ivanov 9832267904 Issue #1566 . DesignForExtension was suppresed in checkstyle code validation till next major release. 2015-08-17 15:40:56 +03:00
Roman Ivanov e46f03cd72 Issue #1566 . Documentation for DesignForExtension was added. 2015-08-17 15:25:35 +03:00
liscju 1e6dc8f4ea Fix RightCurlyCheck with same option not to rise expression in single-line blocks - issue #1416 2015-08-17 07:40:16 +03:00
Baratali Izmailov 322b8da20f XDoc updated 2015-08-17 07:15:24 +03:00
Michal Kordas 20e6e9afca Decrease visibility of public constructor in non-public classes. #1555
Fixes `PublicConstructorInNonPublicClass` inspection violations.

Description:
>Reports all constructors in non-public classes that are declared public.
2015-08-17 07:13:21 +03:00
Michal Kordas 7b01fc489f Remove non-final static field. #1555
Fixes `StaticNonFinalField` inspection violations.

Description:
>Reports non-final static fields.
2015-08-17 07:12:06 +03:00
Michal Kordas acbc27ee12 Correct names for constants. #1555
Fixes `ConstantNamingConvention` inspection violation in test code.

Description:
>Reports any constants whose names are either too short, too long, or do not follow the specified regular expression pattern. Constants are fields declared static final.
2015-08-17 07:11:05 +03:00
Ilja Dubinin 828e07e15b Short-circuit logic should be used in boolean contexts. Issue #46 2015-08-17 07:06:00 +03:00
Ruslan Diachenko 23c8774d2e Issue #1566: AvoidInlineConditional violations fixed 2015-08-17 07:01:20 +03:00
Michal Kordas 9f93c2258e Add private constructor to test utility class. #1555
Fixes `UtilityClassWithoutPrivateConstructor` inspection violation.

Description:
>Reports utility classes which do not have private constructors. Utility classes have all fields and methods declared static. Giving such classes a private constructor prevents them from being inadvertently instantiated.
2015-08-17 06:54:36 +03:00
Michal Kordas 902e761e1a Use diamond operator in test code. #1555
Fixes `Convert2Diamond` inspection violations.

Description:
>This inspection reports all new expressions with type arguments which can be replaced with diamond type <>
Such <> syntax is not supported under Java 1.6 or earlier JVMs.
2015-08-17 06:53:27 +03:00
Michal Kordas f45fee0aa4 Replace for with foreach in test code. #1555
Fixes `ForCanBeForeach` inspection violations in test code.

Description:
>Reports for loops which iterate over collections or arrays, and can be replaced with the foreach iteration syntax, available in Java 5 and newer.
2015-08-17 06:52:33 +03:00
Michal Kordas 1079f0ab99 Remove unnecessary boxing in test code. #1555
Fixes `UnnecessaryBoxing` inspection violations in test code.

Description:
>Reports "boxing", e.g. wrapping of primitive values in objects. Boxing is unnecessary under Java 5 and newer, and can be safely removed.
This inspection only reports if the project or module is configured to use a language level of 5.0 or higher.
2015-08-17 06:51:40 +03:00
Michal Kordas a5df850a23 Convert parameters to varargs in test code. #1555
Fixes `MethodCanBeVariableArityMethod` inspection violations in test code.

Description:
>Reports methods with which can be converted to be a variable arity/varargs method, available in Java 5 and newer.
This inspection only reports if the project or module is configured to use a language level of 5.0 or higher.
2015-08-17 06:50:53 +03:00
Michal Kordas 0dc2233434 Replace <code> tags with {@code ...} constructs in test code. #1555
Fixes `HtmlTagCanBeJavadocTag` inspection violation in test code.

Description:
>Reports use of <code> tags in Javadoc comments. Since JDK1.5 these constructs may be replaced with {@code ...} constructs. This allows the use of angle brackets (<, >) inside the comment, instead of HTML character entities.
2015-08-17 06:49:46 +03:00
Michal Kordas 4074ab454e Use assertSame instead of assertEquals where possible. #1555
Fixes `AssertEqualsMayBeAssertSame` inspection violation in test code.

Description:
>Reports any calls to org.junit.Assert.assertEquals() or junit.framework.Assert.assertEquals() which can be replaced with an equivalent call to assertSame(). This is possible when the arguments are instances of a final class which does not override the equals() method.
2015-08-17 06:48:56 +03:00
Michal Kordas de8f91ad67 Flip misordered assertEquals parameters. #1555
Fixes `MisorderedAssertEqualsParameters` inspection violation in test code.

Description:
>Reports any calls to JUnit assertEquals() which have a non-literal as the expected result argument and a literal as the actual result argument. Such calls will behave fine for assertions which pass, but may give confusing error reports if their expected and actual arguments differ.
2015-08-17 06:47:53 +03:00
Michal Kordas e6faf188e2 Make inner class static. #1555
Fixes `InnerClassMayBeStatic` inspection violation in test code.

Description:
>Reports any inner classes which may safely be made static. An inner class may be static if it doesn't reference its enclosing instance.
 A static inner class does not keep an implicit reference to its enclosing instance. This prevents a common cause of memory leaks and uses less memory per instance of the class.
2015-08-17 06:45:04 +03:00
Michal Kordas f0c74333de Fix UnsupportedOperationException in GUI. #1718 2015-08-17 06:43:18 +03:00
Michal Kordas 7e1d5d0a2d Use float in canonical form in test code. #1555
Fixes `ConfusingFloatingPointLiteral` inspection violation in test code.

Description:
>Reports any floating point numbers which do not have a decimal point, numbers before the decimal point, and numbers after the decimal point. Such literals may be confusing, and violate several coding standards.
2015-08-17 06:41:50 +03:00