-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch order of literals to prevent NullPointerException #868
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,8 +82,8 @@ private String checkScope(String scope) { | |
return null; | ||
} | ||
|
||
if (!scope.equalsIgnoreCase("ORG") | ||
&& !scope.equalsIgnoreCase("PROJECT")) { | ||
if (!"ORG".equalsIgnoreCase(scope) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checked before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose of this change is to be proactively defensive. Though it may be negligibly faster to run this way, it also conforms to a best practice and makes the code easier to read. Also, since the behavior is otherwise equivalent, there is no cost to this change. |
||
&& !"PROJECT".equalsIgnoreCase(scope)) { | ||
|
||
throw new IllegalArgumentException("Unknown scope '" + scope + "', expected: org or project"); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ public void checkPermission(Permission perm) { | |
String path = perm.getName(); | ||
|
||
// allow all local paths | ||
if (!path.startsWith("/") && !path.equals(ALL_FILES_TOKEN)) { | ||
if (!path.startsWith("/") && !ALL_FILES_TOKEN.equals(path)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cannot be null here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose of this change is to be proactively defensive. Though it may be negligibly faster to run this way, it also conforms to a best practice and makes the code easier to read. Also, since the behavior is otherwise equivalent, there is no cost to this change. |
||
return; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -278,7 +278,7 @@ default Set<VariableMapping> getVarMap(Map<String, Object> options, String key) | |
result.add(new VariableMapping(null, sourceExpr, sourceValue, target, true)); | ||
} | ||
|
||
if (key.equals("in") && getWithItems(options) != null) { | ||
if ("in".equals(key) && getWithItems(options) != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose of this change is to be proactively defensive. Though it may be negligibly faster to run this way, it also conforms to a best practice and makes the code easier to read. Also, since the behavior is otherwise equivalent, there is no cost to this change. |
||
result = appendWithItemsVar(result); | ||
} | ||
return result; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,7 +95,7 @@ private static String getEntryPoint(Trigger t) { | |
|
||
private static void validateSpec(Trigger t, List<String> errors) { | ||
String triggerName = t.name(); | ||
if (!triggerName.equals("cron")) { | ||
if (!"cron".equals(triggerName)) { | ||
return; | ||
} | ||
|
||
|
@@ -121,7 +121,7 @@ private static void validateSpec(Trigger t, List<String> errors) { | |
|
||
private static void validateTimezone(Trigger t, List<String> errors) { | ||
String triggerName = t.name(); | ||
if (!triggerName.equals("cron")) { | ||
if (!"cron".equals(triggerName)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe useful? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose of this change is to be proactively defensive. Though it may be negligibly faster to run this way, it also conforms to a best practice and makes the code easier to read. Also, since the behavior is otherwise equivalent, there is no cost to this change. |
||
return; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,7 +260,7 @@ private UserType assertUserType(String username, String domain, UserType type) { | |
} | ||
|
||
private UserType assertSsoUserType(UserPrincipal u, UserType type) { | ||
if (u.getRealm().equals(SSO_REALM_NAME)) { | ||
if (SSO_REALM_NAME.equals(u.getRealm())) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not. |
||
if (userInfoProviders.get(UserType.SSO) != null) { | ||
return UserType.SSO; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,7 +118,7 @@ public String getConfirmationMessage() { | |
|
||
@Override | ||
public void setUp() { | ||
if (this.skip.equals("true")) { | ||
if ("true".equals(this.skip)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. |
||
this.token = null; | ||
return; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,7 @@ public AuthenticationToken createToken(ServletRequest request, ServletResponse r | |
String header = req.getHeader(AUTHORIZATION_HEADER); | ||
if (header != null) { | ||
String[] as = header.split(" "); | ||
if (as.length != 2 || !as[0].equals(HEADER_PREFIX)) { | ||
if (as.length != 2 || !HEADER_PREFIX.equals(as[0])) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cannot be null. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose of this change is to be proactively defensive. Though it may be negligibly faster to run this way, it also conforms to a best practice and makes the code easier to read. Also, since the behavior is otherwise equivalent, there is no cost to this change. |
||
return null; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.