Fix line length warnings

Update the Checkstyle configuration to only warn on lines that exceed
150 characters.

In code reviews we usually ask people to wrap lines at around 80 columns,
but there are too many existing long lines (between 80 and 150) to bother
fixing them all now.

Only wrap the ones that are egregiously long (i.e. more than 150) and add
suppressions for the ones that cannot be wrapped, for example containing
long URLs.

Change-Id: I09625efa7a0509f1d88c27ebc83dda67b6afd026
This commit is contained in:
David Pursehouse 2015-03-16 18:21:05 +09:00
parent d3dcb36cde
commit 410a066be7
8 changed files with 48 additions and 19 deletions

View File

@ -114,7 +114,9 @@ public class ActionContext extends JavaScriptObject {
return e.options[e.selectedIndex].text;
},
popup: function(e){this._p=@com.google.gerrit.client.api.PopupHelper::popup(Lcom/google/gerrit/client/api/ActionContext;Lcom/google/gwt/dom/client/Element;)(this,e)},
popup: function(e){
this._p=@com.google.gerrit.client.api.PopupHelper::popup(
Lcom/google/gerrit/client/api/ActionContext;Lcom/google/gwt/dom/client/Element;)(this,e)},
hide: function() {
this._p.@com.google.gerrit.client.api.PopupHelper::hide()();
delete this['_p'];
@ -125,11 +127,18 @@ public class ActionContext extends JavaScriptObject {
if (m == 'get' || m == 'delete' || i==null) this[m](b);
else this[m](i,b);
},
get: function(b){@com.google.gerrit.client.api.ActionContext::get(Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;)(this._u,b)},
post: function(i,b){@com.google.gerrit.client.api.ActionContext::post(Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/core/client/JavaScriptObject;)(this._u,i,b)},
put: function(i,b){@com.google.gerrit.client.api.ActionContext::put(Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/core/client/JavaScriptObject;)(this._u,i,b)},
'delete': function(b){@com.google.gerrit.client.api.ActionContext::delete(Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;)(this._u,b)},
del: function(b){@com.google.gerrit.client.api.ActionContext::delete(Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;)(this._u,b)},
get: function(b){@com.google.gerrit.client.api.ActionContext::get(
Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;)(this._u,b)},
post: function(i,b){@com.google.gerrit.client.api.ActionContext::post(
Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/core/client/JavaScriptObject;)(
this._u,i,b)},
put: function(i,b){@com.google.gerrit.client.api.ActionContext::put(
Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/core/client/JavaScriptObject;)(
this._u,i,b)},
'delete': function(b){@com.google.gerrit.client.api.ActionContext::delete(
Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;)(this._u,b)},
del: function(b){@com.google.gerrit.client.api.ActionContext::delete(
Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;)(this._u,b)},
};
}-*/;

View File

@ -61,11 +61,18 @@ final class Plugin extends JavaScriptObject {
screen: function(p,c){G._screen(this.name,p,c)},
url: function (u){return G.url(this._url(u))},
get: function(u,b){@com.google.gerrit.client.api.ActionContext::get(Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;)(this._api(u),b)},
post: function(u,i,b){@com.google.gerrit.client.api.ActionContext::post(Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/core/client/JavaScriptObject;)(this._api(u),i,b)},
put: function(u,i,b){@com.google.gerrit.client.api.ActionContext::put(Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/core/client/JavaScriptObject;)(this._api(u),i,b)},
'delete': function(u,b){@com.google.gerrit.client.api.ActionContext::delete(Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;)(this._api(u),b)},
del: function(u,b){@com.google.gerrit.client.api.ActionContext::delete(Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;)(this._api(u),b)},
get: function(u,b){@com.google.gerrit.client.api.ActionContext::get(
Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;)(this._api(u),b)},
post: function(u,i,b){@com.google.gerrit.client.api.ActionContext::post(
Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/core/client/JavaScriptObject;)(
this._api(u),i,b)},
put: function(u,i,b){@com.google.gerrit.client.api.ActionContext::put(
Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/core/client/JavaScriptObject;)(
this._api(u),i,b)},
'delete': function(u,b){@com.google.gerrit.client.api.ActionContext::delete(
Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;)(this._api(u),b)},
del: function(u,b){@com.google.gerrit.client.api.ActionContext::delete(
Lcom/google/gerrit/client/rpc/RestApi;Lcom/google/gwt/core/client/JavaScriptObject;)(this._api(u),b)},
_loadedGwt: function(){@com.google.gerrit.client.api.PluginLoader::loaded()()},
_api: function(u){return @com.google.gerrit.client.rpc.RestApi::new(Ljava/lang/String;)(this._url(u))},

View File

@ -68,7 +68,8 @@ class RelatedChangesTab implements IsWidget {
AbstractImagePrototype.create(Gerrit.RESOURCES.arrowRight()).getSafeHtml();
private static final native String init(String o) /*-{
$wnd[o] = $entry(@com.google.gerrit.client.change.RelatedChangesTab::onOpen(Lcom/google/gwt/dom/client/NativeEvent;Lcom/google/gwt/dom/client/Element;));
$wnd[o] = $entry(@com.google.gerrit.client.change.RelatedChangesTab::onOpen(
Lcom/google/gwt/dom/client/NativeEvent;Lcom/google/gwt/dom/client/Element;));
return o + '(event,this)';
}-*/;

View File

@ -960,7 +960,8 @@ public class RestApiServlet extends HttpServlet {
if (user instanceof AnonymousUser) {
throw new AuthException("Authentication required");
} else if (!globals.webSession.get().isAccessPathOk(AccessPath.REST_API)) {
throw new AuthException("Invalid authentication method. In order to authenticate, prefix the REST endpoint URL with /a/ (e.g. http://example.com/a/projects/).");
throw new AuthException("Invalid authentication method. In order to authenticate, "
+ "prefix the REST endpoint URL with /a/ (e.g. http://example.com/a/projects/).");
}
}
user.setAccessPath(AccessPath.REST_API);

View File

@ -109,7 +109,8 @@ final class CreateProjectCommand extends SshCommand {
requireChangeID = InheritableBoolean.TRUE;
}
@Option(name = "--create-new-change-for-all-not-in-target", aliases = {"--ncfa"}, usage = "if a new change will be created for every commit not in target branch")
@Option(name = "--create-new-change-for-all-not-in-target", aliases = {"--ncfa"},
usage = "if a new change will be created for every commit not in target branch")
void setNewChangeForAllNotInTarget(@SuppressWarnings("unused") boolean on) {
createNewChangeForAllNotInTarget = InheritableBoolean.TRUE;
}
@ -124,7 +125,8 @@ final class CreateProjectCommand extends SshCommand {
@Option(name = "--max-object-size-limit", usage = "max Git object size for this project")
private String maxObjectSizeLimit;
@Option(name = "--plugin-config", usage = "plugin configuration parameter with format '<plugin-name>.<parameter-name>=<value>'")
@Option(name = "--plugin-config",
usage = "plugin configuration parameter with format '<plugin-name>.<parameter-name>=<value>'")
private List<String> pluginConfigValues;
private String projectName;

View File

@ -73,7 +73,9 @@ public class ReviewCommand extends SshCommand {
private final Set<PatchSet> patchSets = new HashSet<>();
@Argument(index = 0, required = true, multiValued = true, metaVar = "{COMMIT | CHANGE,PATCHSET}", usage = "list of commits or patch sets to review")
@Argument(index = 0, required = true, multiValued = true,
metaVar = "{COMMIT | CHANGE,PATCHSET}",
usage = "list of commits or patch sets to review")
void addPatchSetId(final String token) {
try {
PatchSet ps = CommandUtils.parsePatchSet(token, db, projectControl,

View File

@ -35,6 +35,7 @@ public class RequestUtil {
* without decoding URL-encoded characters.
*/
public static String getEncodedPathInfo(HttpServletRequest req) {
// CS IGNORE LineLength FOR NEXT 3 LINES. REASON: URL.
// Based on com.google.guice.ServletDefinition$1#getPathInfo() from:
// https://github.com/google/guice/blob/41c126f99d6309886a0ded2ac729033d755e1593/extensions/servlet/src/com/google/inject/servlet/ServletDefinition.java
String servletPath = req.getServletPath();

View File

@ -14,10 +14,12 @@ edited to remove noisy warnings.
<property name="severity" value="warning"/>
<property name="charset" value="UTF-8"/>
<module name="TreeWalker">
<module name="FileContentsHolder"/>
<module name="OuterTypeFilename"/>
<module name="LineLength">
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
<property name="max" value="100"/>
<property name="max" value="150"/>
<property name="tabWidth" value="2"/>
</module>
<module name="OneTopLevelClass"/>
<module name="NoLineWrap"/>
@ -27,9 +29,8 @@ edited to remove noisy warnings.
</module>
<module name="NeedBraces"/>
<module name="LeftCurly">
<property name="maxLineLength" value="100"/>
<property name="maxLineLength" value="150"/>
</module>
<module name="RightCurly"/>
<module name="RightCurly">
<property name="option" value="alone"/>
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
@ -100,4 +101,9 @@ edited to remove noisy warnings.
<property name="eachLine" value="true"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
</module>
<module name="SuppressWithNearbyCommentFilter">
<property name="commentFormat" value="CS IGNORE (\w+) FOR NEXT (\d+) LINES\. REASON\: \w+"/>
<property name="checkFormat" value="$1"/>
<property name="influenceFormat" value="$2"/>
</module>
</module>