Main
Main copied to clipboard
Examples for live testing
Here are some example you can paste to your IDE in order to see each tip in action:
import java.util.ArrayList;
import java.util.List;
public class x {
//change param to cent
public int x(int z) {
return x(5);
}
public static void main(String[] args) {
int x = 0;
//change to x++
x += 1;
String str = "hello";
//change to "hello".equals(str)
str.equals("hello");
//remove braces
while(x<4){
x++;
}
//remove braces
if(true){
x++;
}
//change to if(!(x==4)) x++;
if(x == 4)
;
else
x++;
//remove double not
if (!(!(x>4)))
;
//unless nano
Integer t = x>6 ? null : x;
//nullconditional nano
String str2 = str == null ? null : str.toLowerCase();
//defaulsto nano
str2 = str != null ? str : "HELLO";
List<Integer> l = new ArrayList<>();
//lisplastelement nano
l.get(l.size()-1);
//fulentsetter. first click - first setter. second click - second setter.
class B{
private int x;
private double y;
B(){
}
double getY(){
return y;
}
void setX(int ¢){
this.x = ¢;
}
void setY(double ¢){
this.y = ¢;
}
}
}
}
I'm working on a file to include all tippers available. When all tippers are done for next week, I will publish it here
Here is the updated file you should check the plugin with. I'll link it from the issue #1435
import java.util.ArrayList;
import java.util.List;
public class X {
//change param to cent
public int x(int z) {
return x(5);
}
public static void main(String[] args) {
int x = 0;
//change to x++
x += 1;
String str = "hello";
//change to "hello".equals(str)
str.equals("hello");
//remove braces
while(x<4){
x++;
}
//remove braces
if(true){
x++;
}
//change to if(!(x==4)) x++;
if(x == 4)
;
else
x++;
//remove double not
if (!(!(x>4)))
;
//unless nano
Integer t = x>6 ? null : x;
//nullconditional nano
String str2 = str == null ? null : str.toLowerCase();
//defaulsto nano
str2 = str != null ? str : "HELLO";
List<Integer> l = new ArrayList<>();
//lisplastelement nano
l.get(l.size()-1);
// remove redundant try-finally clause
try {
t = 44;
} finally {
}
//fulentsetter. first click - first setter. second click - second setter.
class B{
private int x;
private double y;
B(){
}
double getY(){
return y;
}
void setX(int ¢){
this.x = ¢;
}
void setY(double ¢){
this.y = ¢;
}
}
}
}
This is a permanent issue! please don't close it!
If it is permanent, consider either giving it better description or moving it to wiki.