Commit Graph

4587 Commits

Author SHA1 Message Date
Michal Kordas bee8aab67c Encapsulate package-visible fields. #1555
Fixes `PackageVisibleField` inspection violations.

Description:
>Reports package-visible instance variables. Constants (i.e. variables marked static and final) are not reported.
2015-08-25 13:51:50 +03:00
Michal Kordas 2071f9b542 Add arguments to created exceptions. #1555
Fixes `NewExceptionWithoutArguments` inspection violations.

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-25 13:49:22 +03:00
Michal Kordas b43c32ad0a Use same parameter names in overridden methods. #1555
Fixes some `ParameterNameDiffersFromOverriddenParameter` inspection violations.

Description:
>Reports parameters that have different names from the corresponding parameters in the methods they override. While legal in Java, such inconsistent names may be confusing, and lessen the documentation benefits of good naming practices.
2015-08-25 13:48:40 +03:00
Ruslan Diachenko 95604498da Issue #1566: JavadocStyle violations fixed 2015-08-25 13:39:25 +03:00
Michal Kordas 0aec69c702 Fix suspicious getters and setters. #1555
Fixes `SuspiciousGetterSetter` inspection violations.

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-25 13:34:08 +03:00
Michal Kordas 80ab48f859 Remove declared error that should not occur. #1555
Fixes `ErrorRethrown` inspection violations.

Description:
>Reports try statements which catch java.lang.Error or any subclass and which do not rethrow the error. Statements which catch java.lang.ThreadDeath are not reported by this inspection.
2015-08-25 13:32:41 +03:00
Michal Kordas 13c022282b Remove unused import from test code. #1555
Fixes `UnusedImport` inspection violations.

Description:
>Reports any import statements that are unused.
2015-08-25 13:29:49 +03:00
Michal Kordas a992ca414f Specify charset used in test code. #1555
Fixes `ImplicitDefaultCharsetUsage` inspection violations.

Description:
>Reports method and constructor calls which implicitly use the platform's default charset. These can produce different results on (e.g. foreign language) systems that use a different default charset, resulting in unexpected behaviour.
2015-08-25 13:28:32 +03:00
Michal Kordas 4088948e24 Mark field as final. #1555
Fixes `CanBeFinal` inspection violations.

Description:
>This inspection reports all fields, methods or classes, found in the specified inspection scope, that may have a final modifier added to their declarations.
2015-08-25 13:26:36 +03:00
Baratali Izmailov 8d727a31ac Issue #1566: TrailingCommentCheck was added to checkstyle_checks.xml. False-positives were added to suppressions 2015-08-25 13:25:46 +03:00
Baratali Izmailov ee797434bc Issue #1566: Fixed TrailingComment violations in UTs 2015-08-25 13:25:46 +03:00
Michal Kordas 80f66e1c88 Use only one exception on throws list for tests. #1555
Fixes `MultipleExceptionsDeclaredOnTestMethod` inspection violation

Description:
>Reports JUnit test methods with more than one exception declared in the throws clause. Such a throws clause can be more concisely declared as `throws Exception`.
2015-08-25 13:24:26 +03:00
Michal Kordas 07ffe4625f Use constants for arrays initialized with zero length. #1555
Fixes `ZeroLengthArrayInitialization` inspection violation

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-25 13:23:42 +03:00
Michal Kordas e8c6134660 Fix local variable name in test code. #1555
Fixes `LocalVariableNamingConvention` inspection violations in test code.

Description:
>Reports local variables whose names are either too short, too long, or do not follow the specified regular expression pattern.
2015-08-25 13:22:57 +03:00
Michal Kordas 859c809b05 Use relative alignment constants. #1555
Fixes `AbsoluteAlignmentInUserInterface` inspection violations.

Description:
>Reports usages of absolute alignment constants from AWT and Swing. Internationalized applications should make use of relative alignment, because it respects locale component orientation settings.
2015-08-25 13:21:31 +03:00
Michal Kordas dc0a1a2fcc Mark fields as private static final in test code. #1555
Fixes `FieldMayBeStatic` inspection violations in test code.

Description:
>Reports any instance variables which may safely be made static. A field may be static if it is declared final, and is initialized with a constant
2015-08-25 13:20:01 +03:00
Michal Kordas a244f05705 Remove calls to simple getters withing classes. #1555
Fixes `CallToSimpleGetterInClass` inspection violations.

Description:
>Reports any calls to a simple property getter from within the property's class. A simple property getter is defined as one which simply returns the value of a field, and does no other calculation. Such simple getter calls may be safely inlined, at a small performance improvement. Some coding standards also suggest against the use of simple getters for code clarity reasons.
2015-08-25 13:05:51 +03:00
Michal Kordas c75c9f00ac Use serializable type of field in serializable class. #1555
Fixes `NonSerializableFieldInSerializableClass` 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-25 13:04:44 +03:00
Michal Kordas 230cd73883 Rename field to not interfere with local variable name. #1555
Fixes `LocalVariableHidingMemberVariable` inspection violation in test code.

Description:
>Reports local variables named identically to visible fields of their class or surrounding classes if it is a local variable inside of an inner or anonymous class. Such a variable name may be confusing.
2015-08-25 13:03:50 +03:00
Baratali Izmailov 0c75b3af74 Issue #1566: New Checks added to checkstyle_checks config 2015-08-22 08:25:42 -04:00
Michal Kordas abfc952fd0 Fix suspicious getters and setters. #1555
Fixes `SuspiciousGetterSetter` inspection violations.

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-22 14:43:09 +03:00
Michal Kordas 16512bb1e7 Decrease scope of variables. #1555
Fixes `TooBroadScope` inspection violations.

Description:
>Reports any variable declarations of which the scope can be narrowed. Especially useful for "Pascal style" declarations at the start of a method, but variables with too broad a scope are also often left over after refactorings.
2015-08-22 14:41:17 +03:00
Michal Kordas dad4fa599a Fix variables with standard names. #1555
Fixes `StandardVariableNames` inspection violations in test code.

Description:
>Reports on any variables with 'standard' names which are of unexpected types. Such names may be confusing. Standard names and types are as follows:
- i, j, k, m, n - int
- f - float
- d - double
- b - byte
- c, ch - char
- l - long
- s, str - String
2015-08-22 14:40:19 +03:00
Michal Kordas a13ebd482c Use constant for arrays with zero length. #1555
Fixes `ZeroLengthArrayInitialization` inspection violations in test code.

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-22 14:38:41 +03:00
Michal Kordas 04182c6064 Remove unused import from test code. #1555
Fixes `UnusedImport` inspection violations.

Description:
>Reports any import statements that are unused.
2015-08-22 14:37:48 +03:00
Michal Kordas 3d7dcc51c4 Remove duplicates in throws lists. #1555
Fixes `DuplicateThrows` inspection violations.

Description:
>This inspection reports duplicate exceptions in a method throws list.
2015-08-22 14:37:15 +03:00
Michal Kordas d5129db907 Remove unnecessary local variables. #1555
Fixes `UnnecessaryLocalVariable` inspection violations.

Description:
>Reports unnecessary local variables, which add nothing to the comprehensibility of a method. Variables caught include local variables which are immediately returned, local variables that are immediately assigned to another variable and then not used, and local variables which always have the same value as another local variable or parameter.
2015-08-22 14:36:33 +03:00
Michal Kordas 27375d0815 Invert negated if-else. #1555
Fixes `NegatedIfElse` inspection violations.

Description:
>Reports if statements which contain else branches and whose conditions are negated. Flipping the order of the if and else branches will usually increase the clarity of such statements.
2015-08-22 14:35:35 +03:00
Michal Kordas d1f4e8d400 Simplify and remove unnecessary code. #1555
Fixes a few violations.
2015-08-22 14:34:52 +03:00
Michal Kordas 8abfa48f2e 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-22 14:33:46 +03:00
Michal Kordas 3b452a2e88 Inline calls to simple getters. #1555
Fixes `CallToSimpleGetterInClass` inspection violations.

Description:
>Reports any calls to a simple property getter from within the property's class. A simple property getter is defined as one which simply returns the value of a field, and does no other calculation. Such simple getter calls may be safely inlined, at a small performance improvement. Some coding standards also suggest against the use of simple getters for code clarity reasons.
2015-08-22 14:32:47 +03:00
Michal Kordas 19d1fb3602 Use ignored results of calling methods in test code. #1555
Fixes `IgnoreResultOfCall` inspection violations in test code.

Description:
>Reports any calls to specific methods where the result of that call is ignored. Both methods specified in the inspection's settings and methods annotated with org.jetbrains.annotations.Contract(pure=true) are checked. For many methods, ignoring the result is perfectly legitimate, but for some methods it is almost certainly an error. Examples of methods where ignoring the result of a call is likely to be an error include java.io.inputStream.read(), which returns the number of bytes actually read, any method on java.lang.String or java.math.BigInteger, as all of those methods are side-effect free and thus pointless if ignored.
2015-08-22 14:31:32 +03:00
Michal Kordas a846ef9d33 Remove usage of null as argument to varagrs in test code. #1555
Fixes `NullArgumentToVariableArgMethod` inspection violations in test code.

Description:
>Reports any calls to a variable-argument method which has a null in the variable-argument position (e.g System.out.printf("%s", null) ). Such a null argument may be confusing, as it is not wrapped as a single-element array, as may be expected.
2015-08-22 14:30:28 +03:00
Michal Kordas 555478f967 Create new instance using constructor in test code. #1555
Fixes `ClassNewInstance` inspection violations in test code.

Description:
>Reports any calls to java.lang.Class.newInstance(). The newInstance method propagates any exception thrown by the no-arg constructor, including checked exceptions. Use of this method effectively bypasses the compile-time exception checking that would otherwise be performed by the compiler. Replacing such a method call with a call to the java.lang.reflect.Constructor.newInstance() method avoids this problem by wrapping any exception thrown by the constructor in a java.lang.reflect.InvocationTargetException.
2015-08-22 14:29:30 +03:00
Michal Kordas 70ac1c44d9 Do not use Properties as Hashtable. #1555
Fixes `UseOfPropertiesAsHashtable` inspection violations in test code.

Description:
>Reports any calls to the java.util.Hashtable methods put(), putAll() or get() on a java.util.Properties object. For reasons lost to history, Properties inherits from Hashtable, but use of those methods is discouraged to prevent corruption of properties values with non-String data.
2015-08-22 14:28:37 +03:00
Michal Kordas 1c9034402f Do not use static field referenced by subclass. #1555
Fixes `StaticFieldReferenceOnSubclass` inspection violations.

Description:
>Reports static field accesses where the call is qualified by a subclass of the declaring class, rather than the declaring class itself. Java allows such qualification, but such accesses may be confusing, and may indicate a subtle confusion of inheritance and overriding.
2015-08-21 21:17:54 +02:00
Baratali Izmailov 82e3e077f4 Issue #1566: Class 'AbstractCellEditor' must be declared as 'abstract' 2015-08-21 16:34:33 +03:00
Ruslan Diachenko 56c745bef6 Issue #1566: JavadocStyle violation fixed 2015-08-21 16:32:56 +03:00
Ruslan Diachenko 32d84c500d Issue #1566: fixed import order 2015-08-21 16:17:49 +03:00
Michal Kordas 984409e0cd Add missing space in JavaScript code. #1555
Fixes some `JSLint` inspection violations.

Description:
>JSLint: Missing space between 'for' and '('. (at line 9)
2015-08-21 16:17:03 +03:00
Michal Kordas 7e6f2135a9 Remove unnecessary toString() call in test code. #1555
Fixes `UnnecessaryToStringCall` inspection violations in test code.

Description:
>Reports on any calls to toString() used in string concatenations and as arguments to the print() and println() methods of java.io.PrintWriter and java.io.PrintStream, the append() method of java.lang.StringBuilder and java.lang.StringBuffer or the trace(), debug(), info(), warn() and error() methods of org.slf4j.Logger. In these cases the conversion to string will be handled by the underlying library methods and an explicit call to toString() is no needed.
Note that without the toString() call the expression will have slightly different semantics (the string null will be used instead of throwing a NullPointerException).
2015-08-21 16:16:01 +03:00
Michal Kordas 4cdea36a1e 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-21 16:14:25 +03:00
Michal Kordas aa950f0697 Remove unnecessarily qualified statically imported elements. #1555
Fixes `UnnecessarilyQualifiedStaticallyImportedElement` inspection violations in test code.

Description:
>Reports any references to static members which are statically imported and also qualified with their containing class name. Because the elements are already statically imported such qualification is unnecessary and can be removed.
2015-08-21 16:13:37 +03:00
Michal Kordas 613ac4bb77 Remove unnecessary constant array creation expressions. #1555
Fixes `UnnecessaryConstantArrayCreationExpression` inspection violations in test code.

Description:
>Reports any constant new array expression which can be replaced with an array initializer. Array initializers omit the type declaration because that is already specified by the declaration of the variable the expression is assigned to.
2015-08-21 16:12:44 +03:00
Michal Kordas 074b36894e Remove unnecessary parentheses in test code. #1555
Fixes `UnnecessaryParentheses` inspection violations in test code.

Description:
>Reports on any instance of unnecessary parentheses. Parentheses are considered unnecessary if the evaluation order of an expression remains unchanged if the parentheses are removed.
2015-08-21 16:11:45 +03:00
Michal Kordas 885fca8fe9 Remove call to printStackTrace() in test code. #1555
Fixes `ThrowablePrintStackTrace` inspection violations in test code.

Description:
>Reports any calls to Throwable.printStackTrace() without arguments. Such statements are often used for temporary debugging, and should probably be either removed from production code, or replaced with a more robust logging facility.
2015-08-21 16:11:08 +03:00
Michal Kordas b543f32fd7 Use field that was unused and remove suppression. #1555
Fixes `SuppressionAnnotation` inspection violations in test code.

Description:
>Reports any inspection suppression comments or annotations.
2015-08-21 16:10:34 +03:00
Michal Kordas cea7f4acbe Remove redundant throws. #1555
Fixes `RedundantThrows` inspection violations in test code.

Description:
>This inspection reports exceptions that are declared in a method's signature but never thrown by the method itself or its implementations/derivatives.
2015-08-21 16:09:26 +03:00
Michal Kordas 5e1cf30d49 Add missing locale to String case conversions in test code. #1555
Fixes `StringToUpperWithoutLocale` inspection violations in test code.

Description:
>Reports any call of toUpperCase() or toLowerCase() on String objects which do not specify a java.util.Locale. Such calls are usually incorrect in an internationalized environment.
2015-08-21 16:08:19 +03:00
Michal Kordas 3db243d947 Use String instead of constant in test code. #1555
Fixes `NumericToString` inspection violations in test code.

Description:
>Reports any call of toString() on numeric objects. Such calls are usually incorrect in an internationalized environment.
2015-08-21 16:07:47 +03:00