sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Canoncializing the Code

Open MeFisto94 opened this issue 7 years ago • 1 comments

Hey Guys, Since I've just lost many lines of exhausting work thanks to my Git UI, I thought why not splitting this easy task up on many people, so everyone is only a bit exhausted.

It's also a great chance to learn how to fork projects and creating pull requests without having to solve complex coding problems.

The fix consists of three stages, but I might do the third stage on my own. For the git commit message, a layout of 1./2./3. Canoncialization of jme3-modulename (#<Issue>) is preferred, make sure to not include "fix(es)" in your commit message though. Ex: 2. Canoncialization of jme3-scenecomposer (#155).

If you follow that, everyone can see below which modules have passed which stage of canoncialization.

  1. Canoncialization:
  • Removing "junk" (that's things like: "license.txt not found", "To change this, see Tools -> Templates", which might even be in some of the xml files)
  • Updating/adding the LICENSE (if you find that this comment is present, just update it so it includes 2018 (e.g. 2003-2018).
/*
 * Copyright (c) 2018 jMonkeyEngine
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * * Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 * 
 * * Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 * 
 * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
 *   may be used to endorse or promote products derived from this software
 *   without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
  1. Canoncialization:
  • Select all code in Netbeans (can also be the SDK) and select Source -> Format. Keep an eye on Annotations though, sometimes it creates mess which we don't want.
  • Follow the Warnings which Netbeans shows and let it auto-fix it (clicking the lamp). These specifically include: Missing @Override, use of Iterator instead of for-each loop or redundant if statements (instead of return isTrue() rather if (isTrue()) { return true; } else { return false; }.
  1. Canoncialization:
  • Use ExceptionUtils.caughtException(ex) where applicable(!). This means that InterruptedExceptions should be handled by Thread.currentThread().interrupt() and sometimes the control flow is used to Exceptions (i.e. the caller can't handle a returning null or something, see welcome screen's rss handler).
  • Also make use of the message parameter in ExceptionUtils.caughtException(ex, message) (e.g. in ModelImporter: Notify the user that this might be a faulty model and he/she/it should ask for troubleshooting on the hub first.

MeFisto94 avatar Jan 22 '18 22:01 MeFisto94

All license headers can be changed automatically with this plugin in Netbeans:

http://timboudreau.com/modules/download/org.netbeans.modules.licensechanger/1ycp5lzwoigko15tsxnim0nydiw6119m.nbm

The download page is here: https://timboudreau.com/modules

nureyev avatar Jan 23 '18 03:01 nureyev