Commit Graph

3373 Commits

Author SHA1 Message Date
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 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
Andrei Selkin 77c3f22326 Provided UTs for getRequiredTokens and getAcceptableTokens, issue #655 2015-08-17 06:41:03 +03:00
Andrei Selkin d56a2a366c Updated all checks to have getRequiredTokens and getAcceptableTokens, issue #655 2015-08-17 06:41:03 +03:00
Michal Kordas eeb20e6c8c Correct name of exception. #1555
Fixes `ExceptionNameDoesntEndWithException` inspection violation in test code.

Description:
>Reports exception classes whose names don't end with 'Exception'.
2015-08-16 23:08:23 +02:00
Roman Ivanov 5630e4399b Issue #1243: Added serialId to test classes 2015-08-16 14:47:17 +03:00
Roman Ivanov 80e0a90fb8 Issue #1243: Eclipse warnings are fixed 2015-08-16 08:23:07 +03:00
Roman Ivanov 617b099c97 fix for Eclipse compiler error 2015-08-16 07:54:15 +03:00
Aleksandr Ivanov cd12de2a24 Extended messages for CustomImportOrder #1648 2015-08-16 07:15:10 +03:00
Michal Kordas 26774cf310 Remove calls to simple setters from within classes. #1555
Fixes `CallToSimpleSetterInClass` inspection violations.

Description:
>Reports any calls to a simple property setter from within the property's class. A simple property setter is defined as one which simply assigns the value of its parameter to a field, and does no other calculation. Such simple setter calls may be safely inlined, at a small performance improvement. Some coding standards also suggest against the use of simple setters for code clarity reasons.
2015-08-16 07:03:15 +03:00
Michal Kordas 1ab08ad4ab Make methods static. #1555
Fixes `MethodMayBeStatic` inspection violations.

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-16 07:02:36 +03:00
Michal Kordas c0a69490d7 Remove string concatenation in format string argument. #1555
Fixes `StringConcatenationInFormatCall` inspection violations.

Description:
>Reports non-constant string concatenations used as a format string argument. Often this is the result of mistakenly concatenating a string format argument by typing a '+' when a ',' was meant. This inspection checks calls to appropriate methods on java.util.Formatter, java.lang.String, java.io.PrintWriter, or java.io.PrintStream.
2015-08-16 07:01:24 +03:00
Michal Kordas 931af7ec14 Simplify expressions that are constant. #1555
Fixes `ConstantConditions` inspection violations.

Description:
>This inspection analyzes method control and data flow to report possible conditions that are always true or false and expressions whose value is statically proven to be constant.
2015-08-16 07:00:45 +03:00
Michal Kordas e936c4c6fa Remove unnecessary synchronization. #1555
Fixes `NonSerializableFieldInSerializableClass` inspection violation.

Description:
>Reports non-synchronized methods overriding synchronized methods.

Fixes `NonSynchronizedMethodOverridesSynchronizedMethod` inspection violation.

Description:
>Reports non-Serializable fields in Serializable classes. Such fields will result in runtime exceptions if the object is serialized. Fields declared transient or static are not reported, nor are fields of classes which have defined a writeObject method. For purposes of this inspection, fields with java.util.Collection or java.util.Map types are assumed to be Serializable, unless the types they are declared to contain are non-Serializable.
2015-08-16 06:55:04 +03:00
Ruslan Diachenko b02d9661f8 Issue #1566: VisibilityModifier violations fixed 2015-08-16 06:52:54 +03:00
Baratali Izmailov 65dd1fac70 Issue #1243: Suppressed LeftCurlyCheck's deprecated field 2015-08-16 06:51:53 +03:00
Baratali Izmailov c4cc403882 Issue #1243: Useless local variable has been removed 2015-08-16 06:51:16 +03:00
Ruslan Diachenko 544e9992af Issue #1566: LineLength violations fixed 2015-08-16 06:50:00 +03:00
Baratali Izmailov 259cc41625 Issue #1243: Output stream has to be closed 2015-08-16 06:23:19 +03:00
Ruslan Diachenko 245ca68d99 Issue #1566: HideUtilityClassConstructor violations fixed 2015-08-16 06:20:41 +03:00
Baratali Izmailov cc1b2e99c3 Issue #1243: Unsafe casts have been suppressed in UTs which use reflection 2015-08-16 06:18:12 +03:00
Baratali Izmailov 6ec212bb5e Issue #1243: Input file to resources folder 2015-08-15 15:53:21 -04:00
Roman Ivanov a15aacf77a fix for build failure 2015-08-15 14:47:45 +03:00
Michal Kordas 6370bd4a8a Do not allocate arrays of zero length. #1555
Fixes `ZeroLengthArrayInitialization` inspection violations.

Description:
>Reports on allocations of arrays with known lengths of zero. Since array lengths in Java are non-modifiable, it is almost always possible to share zero-length arrays, rather than repeatedly allocating new zero-length arrays. Such sharing may provide useful optimizations in program runtime or footprint. Note that this inspection does not report zero-length arrays allocated as static final fields, as it is assumed that those arrays are being used to implement array sharing.
2015-08-15 06:46:26 +03:00
Michal Kordas e72b617d4b Replace <code> tags with {@code ...} constructs. #1555
Fixes `HtmlTagCanBeJavadocTag` inspection violations.

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-15 06:45:50 +03:00
Michal Kordas 020d8b2469 Fix exception creation without any arguments specified. #1555
Fixes `NewExceptionWithoutArguments` inspection violation.

Description:
>Reports exception instance creation without any arguments specified. When an exception is constructed without arguments it contains no information about the fault that happened, which makes debugging needlessly hard.
2015-08-15 06:45:13 +03:00
Michal Kordas 7453d382c1 Decrease visibility of package-local class. #1555
Fixes `PackageVisibleInnerClass` inspection violation.

Description:
>Reports package-local inner classes.
2015-08-15 06:44:32 +03:00
Michal Kordas fe251ed9ff Add missing case in switch. #1555
Fixes `EnumSwitchStatementWhichMissesCases` inspection violation.

Description:
>Reports switch statements over enumerated types which do not include all of the enumerated type's elements as cases.
2015-08-15 06:43:24 +03:00
Michal Kordas 027d1e2c99 Invert conditional expressions that are negated. #1555
Fixes `NegatedConditional` inspection violations.

Description:
>Reports conditional expressions whose conditions are negated. Flipping the order of the conditional expression branches will usually increase the clarity of such statements.
2015-08-15 06:42:50 +03:00
Michal Kordas 02dfe8c7c5 Remove unnecessary this. #1555
Fixes `UnnecessaryThis` inspection violations after recent commits.

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-15 06:42:09 +03:00
Michal Kordas 257983bcbf Mark fields as final. #1555
Fixes `FieldMayBeFinal` inspection violations.

Description:
>Reports any fields which may safely be made final. A static field may be final if it is initialized in its declaration or in one static class initializer, but not both. A non-static field may be final if it is initialized in its declaration or in one non-static class initializer or in all constructors.
2015-08-15 06:41:30 +03:00