Commit Graph

4317 Commits

Author SHA1 Message Date
Michal Kordas e5ec819a74 Replace magic constant occurrences with proper constants. #1555
Fixes MagicConstant violations.

 Description:
> Report occurrences where usages of "magic" constants only are allowed but other expressions are used instead. E.g. new Font("Arial", 2 ) // not allowed instead of new Font("Arial", Font. ITALIC ) // OK   Please see org.intellij.lang.annotations.MagicConstant annotation description for details.
2015-08-09 04:37:34 +03:00
Aleksandr Ivanov 70c83141b4 Changed SAME_PACKAGE rule for CustomImportOrderCheck #1262 2015-08-08 13:01:50 +03:00
Andrei Selkin 2da1686445 Added CommentsIndentationCheck into checkstyle_checks.xml, issue #333. 2015-08-08 11:54:21 +03:00
Andrei Selkin df5eac3757 Added new Check: CommentsIndentationCheck, issue #333 2015-08-08 11:54:21 +03:00
Andrei Selkin 186625600d Resolved javadoc problems that reported by java 8, issue #291. 2015-08-08 08:23:32 +03:00
Michal Kordas f249163027 Replace RuntimeException with IllegalStateException. #1555
Fixes `BadExceptionThrown` inspection violations.

Description:
>Reports throw statements which throw inappropriate exceptions. One use of this inspection would be to warn of throw statements which throw overly generic exceptions (e.g. java.lang.Exception or java.io.IOException).
2015-08-08 08:19:16 +03:00
Michal Kordas 0c61e5d7a5 Remove unchecked exception from throws. #1555
Fixes `ThrowsRuntimeException` inspection violation.

Description:
Reports declarations of unchecked exceptions (RuntimeException and its subclasses) in the throws clause of a method. Declaration of unchecked exceptions are not required and may be removed or moved to a Javadoc @throws tag.
2015-08-08 08:18:30 +03:00
Michal Kordas 4fd298b001 Rename ignored catch parameters. #1555
Fixes `UnusedCatchParameter` inspection violations.

Description:
Reports any catch parameters that are unused in their corresponding blocks. This inspection will not report any catch parameters named "ignore" or "ignored". Conversely this inspection will warn on any catch parameters named "ignore" or "ignored" that are actually used.
2015-08-08 08:17:41 +03:00
Michal Kordas bf6735ce4b Use StringBuilder to concatenate strings. #1555
Fixes `StringReplaceableByStringBuffer` inspection violations.

Description:
Reports any variables declared as java.lang.String which are repeatedly appended to. Such variables may be more efficiently declared as java.lang.StringBuffer or java.lang.StringBuilder.
2015-08-08 08:14:58 +03:00
Michal Kordas b550547318 Make method static. #1555
Fixes `MethodMayBeStatic` inspection violation.

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-08 08:14:05 +03:00
Michal Kordas 084809c3b9 Simplify empty string check. #1555
Fixes `Simplify empty string check` inspection violations.

Description:
>Reports .equals() being called to compare a String with an empty string. It is normally more performant to test a String for emptiness by comparing its .length() to zero instead.
2015-08-08 08:11:31 +03:00
Michal Kordas 717ba0311d Replace toArray() argument with correctly sized array. #1555
Fixes `ToArrayCallWithZeroLengthArrayArgument` inspection violation.

Description:
>Reports any call to toArray() on an object of type or subtype java.util.Collection with a zero-length array argument. When passing in an array of too small size, the toArray() method has to construct a new array of the right size using reflection. This has significantly worse performance than passing in an array of at least the size of the collection itself.
2015-08-08 08:10:24 +03:00
Michal Kordas bd6318bfd2 Replace Arrays.asList() with Collections.singletonList(). #1555
Fixes `ArraysAsListWithZeroOrOneArgument` inspection violation.

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-08 08:09:05 +03:00
Michal Kordas c8430f2d0f Fix comparison of double value with zero. #1555
Fixes `FloatingPointEquality` inspection violation.

Description:
>Reports floating-point values being compared with an == or != operator. Floating point values are inherently inaccurate, and comparing them for exact equality is almost never the desired semantics. This inspection ignores comparisons with zero and infinity literals.
2015-08-08 07:41:10 +03:00
Michal Kordas 4c1148db99 Rename variables with questionable names. #1555
Fixes `QuestionableName` inspection violations.

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.
 Use the list below to specify names which should be reported
2015-08-08 07:40:17 +03:00
Michal Kordas f1e80e4eca Rename variables with 'standard' names of unexpected types. #1555
Fixes `StandardVariableNames` inspection violations.

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-08 07:38:41 +03:00
Michal Kordas 546f336e25 Prevent corrupting Properties with non-String data. #1555
Fixes `UseOfPropertiesAsHashtable` inspection violations.

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-08 07:18:36 +03:00
Michal Kordas a2bfd59729 Replace Class.newInstance() with Constructor.newInstance(). #1555
Fixes ClassNewInstance inspection violation.

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-08 07:17:35 +03:00
Michal Kordas fc10c00e0a Replace subtraction in compareTo() with Integer.compare(). #1555
Fixes SubtractionInCompareTo inspection violations.

Description:
>Reports subtraction in compareTo() methods and methods implementing java.util.Comparator.compare(). While it is a common idiom to use the results of integer subtraction as the result of a compareTo() method, this construct may cause subtle and difficult bugs in cases of integer overflow.
2015-08-08 07:15:28 +03:00
Michal Kordas 2e32ba7ab6 Fix suspicious method call. #1555
Fixes SuspiciousMethodCalls inspection violation.

Description:
>This inspection reports method calls to parameterized collections, where actual argument type does not correspond to the collection's elements type.  For example if you have the following code:
 ```
     List<Integer> list = getListOfElements();
     list.remove("");
 ```
 the call to `remove()` will be highlighted.
2015-08-08 07:13:56 +03:00
Michal Kordas 8a3f5bf6d5 Remove unused assignments. #1555
Fixes UnusedAssignment inspection violations.

Description:
>This inspection points out the cases where a variable value is never used after its assignment, i.e.:
- the variable never gets read after assignment OR
- the value is always overwritten with another assignment before the next variable read OR
 - the variable initializer is redundant (for one of the above two reasons) OR
 - the variable is never used.
2015-08-08 07:12:41 +03:00
Michal Kordas 7d513f08c2 Copy collections and arrays before assigning to fields. #1555
Fixes AssignmentToCollectionFieldFromParameter violations.

 Description:
>Reports any attempt to assign an array or Collection field from a method parameter. Since the array or Collection may have its contents modified by the calling method, this construct may result in an object having its state modified unexpectedly. While occasionally useful for performance reasons, this construct is inherently bug-prone.
2015-08-08 07:11:07 +03:00
Ruslan Diachenko 68959eeeff Issue #1566: AvoidNestedBlocks, FinalLocalVariable, RegexpSingleline (THIS as a lock) violations fixed 2015-08-08 07:08:28 +03:00
Andrei Selkin 782da01103 Fixed overly strong type cast, issue #1555. 2015-08-08 06:59:27 +03:00
Dave Moloney 4d526a44a7 Minor typo: have -> has the 2015-08-08 06:18:24 +03:00
Dave Moloney 7f90c5aef3 Minor typo on site homepage: 'desig' -> 'design' 2015-08-08 06:18:24 +03:00
Roman Ivanov 3c5d80db4c 6.10-SNAPSHOT 2015-08-07 16:57:36 +03:00
Roman Ivanov 2ad80f4e9e [maven-release-plugin] prepare for next development iteration 2015-08-07 15:20:43 +03:00
Roman Ivanov 75be892cb1 [maven-release-plugin] prepare release checkstyle-6.9 2015-08-07 15:20:41 +03:00
Roman Ivanov e04257c669 release notes 6.9 2015-08-07 06:46:50 +03:00
Roman Ivanov f727a3d885 release notes for 6.8.2 2015-08-07 05:53:19 +03:00
Michal Kordas b0d1f7fd52 Remove redundant characters from regular expressions. #1555
Fixes:
* Obsolete single repetition
* Redundant character escapes
2015-08-06 06:32:36 +03:00
Michal Kordas 1df3af1d42 Add tag required by schema to Cobertura configuration. #1555
Fixes IntelliJ IDEA MavenModelInspection violation.
2015-08-06 06:31:48 +03:00
Michal Kordas d2b16c06ed Collapse empty tags in XML. #1555 2015-08-06 06:30:42 +03:00
Baratali Izmailov dd5562f6dc Issue #1293: Improved coverage for ReturnCountCheck 2015-08-06 06:29:22 +03:00
Roman Ivanov 75ddaad1c5 fix for build on windows. #1294 2015-08-06 06:17:12 +03:00
Roman Ivanov ead1a5e5dc 100% UTs coverage for Checker (no way to reproduce/mock IOException). #1294 2015-08-05 17:06:17 +03:00
Roman Ivanov 3fe08f2968 UT coverage for Checker. #1294 2015-08-05 16:27:10 +03:00
Roman Ivanov a2da840df3 100% UTs coverage for TreeWalker. #1294 2015-08-05 15:39:51 +03:00
Roman Ivanov b2d7013e9e UT coverage for TreeWalker. #1294 2015-08-05 08:04:48 +03:00
Andrei Selkin ddafe73dda Fixed incorrect Google Java Style links, issue #751. 2015-08-04 12:02:40 +03:00
Ilja Dubinin 78fbe6abf4 Coverage has been increased to 100% in DescedantTokensCheck. Issue #1290 2015-08-03 20:54:04 -07:00
Andrei Selkin d282d5b8db Refactoring of RightCurlyCheck, issue #1511. 2015-08-03 12:03:09 +03:00
Michal Kordas ef422e76c6 Remove redundant throws declarations. #1542 2015-08-02 18:54:23 -07:00
Michal Kordas c6df309827 Access static members via class reference. #1542 2015-08-02 18:54:23 -07:00
Michal Kordas 59fa63c67d Remove unnecessary qualifiers for statically imported elements. #1542 2015-08-02 18:54:23 -07:00
Michal Kordas f0d637e28c Remove redundant constructor. #1542 2015-08-02 18:54:23 -07:00
Michal Kordas 2880edd655 Decrease scope of variables. #1538 2015-08-02 18:48:58 -07:00
Michal Kordas d49eaaf2e4 Extract increment operations to separate expressions. #1538
While increment or decrement expressions nested inside other expressions are admirably terse, such expressions may be confusing, and violate the general design principle that a given construct should do precisely one thing.
2015-08-02 18:48:58 -07:00
Michal Kordas 85ba2a3dce Replace assignment with operator assignment. #1538 2015-08-02 18:48:58 -07:00