MysteryPancake / Rule-Book

My strict law

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MysteryPancake's Rule Book

Please don't use this rule book. The rules are extremely arbitrary and change all the time.

This is a journal to help me remain consistent. It also helps me spot and fix common mistakes.

GitHub

Generic

  • Repositories must have README files.
  • Editing code directly on this site mustn't occur (too often).
  • Repository names must be capitalized.
  • Repository names must be as short as possible.
  • Repository names must use - to separate words.
  • Repository descriptions mustn't include a full stop.
  • Repository descriptions must be as short as possible.
  • Repositories intended for personal use must include an MIT License with MysteryPancake as the legal name.
  • Repositories intended for external use must include an Unlicense.
  • Variables to insert must be named <VAR>, not INSERT_VAR_HERE.
  • Images in README files must be included in the repository, not on an external site.
  • Commits closing issues must be named resolved, fixes, or resolves, followed by the issue number.
  • Small unused scripts must be added to the Fun repository.

Garry's Mod

  • Repositories intended for external use must be named GMod-<Addon-Name>.
  • Repositories must include the tags garrys-mod, garrysmod, garry-mod, garrysmod-addon, lua, addon, glua, gmod, and gmod-lua.
  • Repositories for Scripted Tools must include the tag garrysmod-tool.
  • Repository descriptions must be <Addon Name> for Garry's Mod.
  • Repositories must include an addon icon and the associated Photoshop file.
  • Repositories must include a link to the addon.
  • Repository README files must use this template:
<img src="<ICON_PATH>?raw=true" width="75" align="left">

# Garry's Mod <Addon Name>
All the code for my <Addon Name> addon can be found here, and the actual addon is available [here](<WORKSHOP_LINK>).

Discord

  • Repositories must include the tags discord, discord-bot, discord-js, discord-api, discordjs, discordjs-bot, javascript, discordjsbot, discordapp, discordbot, nodejs-bot, nodejs, node-js, and bot.
  • Repositories must include a Procfile containing worker: npm start.
  • Repository README files must include setup instructions.
  • Repository README files must include a command list.
  • Repositories must include a bot icon.
  • Repository package.json files must use this template:
{
  "name": "<Repository-Name>",
  "version": "1.0.0",
  "description": "<Repository Description>",
  "main": "<SCRIPT_PATH>",
  "engines": {
    "node": "10.x",
    "npm": "*"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node <SCRIPT_PATH>"
  },
  "keywords": [
    "discord",
    "discord-bot",
    "discord-js",
    "discord-api",
    "discordjs",
    "discordjs-bot",
    "javascript",
    "discordjsbot",
    "discordapp",
    "discordbot",
    "nodejs-bot",
    "nodejs",
    "node-js",
    "bot"
  ],
  "author": "MysteryPancake",
  "license": "MIT",
  "dependencies": {
    "discord.js": "<VERSION>"
  }
}

GitHub Pages

  • Repositories must include the tags github-pages, github-page, github-io, html, css, javascript, github-api, website, online, and all website keywords.
  • Website links must have lowercase domains.
  • Website links mustn't have a / at the end.
  • Repositories must include a website link.

Programming

Generic

  • Functions with applicable default arguments mustn't be called with the arguments.
  • Generic string variables must be named str, not txt, or text.
  • -foo and !foo must be used to invert variables, not foo * -1.
  • Functions with enum arguments mustn't be called with raw values.
  • Literal collections must be on a single line unless wrapping.
  • if statements must be on a single line unless wrapping.
  • if bool then must be used, not if bool == true then.
  • Variables mustn't share the names of existing variables.
  • The last condition of switch statements must break.
  • return early from functions containing lots of code.
  • Functions mustn't have unintentional side effects.
  • application/xml must be used, not text/xml.
  • switch statements mustn't have additional tabs.
  • Unused variables must be set as _, or removed.
  • x *= 0.75 must be used, not x = x - x / 4.
  • Clientside must be used, not client-side.
  • Serverside must be used, not server-side.
  • Multiplication must be used, not division.
  • Powers of two must be used where possible.
  • Triple newlines \n\n\n mustn't be used.
  • Validate, sanitize and escape user data.
  • Variable names must be in camelCase.
  • Generic must be used, not general.
  • No unnecessary variables in loops.
  • Setup must be used, not init.
  • Strings must use ", not '.
  • Errors must be handled safely.
  • No unnecessary ( or ).
  • No unnecessary variables.

Lua

  • tbl[ math.random( #tbl ) ] must be used to get a random value from a table.
  • Sequential tables must be iterated with ipairs or a numeric for loop.
  • next( table ) == nil must be used to check if a string-table is empty.
  • Variables must be local unless intended to be globally overridden.
  • #table == 0 must be used to check if an integer-table is empty.
  • math.random( 1, n ) must be shortened to math.random( n ).
  • Strings in tables must be tbl.string, not tbl[ "string" ].
  • math.random() >= 0.5 must be used to get a random boolean.
  • Unused keys and values in loops must be set as _.
  • Generic table variables must be named tbl.
  • return end must be followed by a newline.
  • not foo must be used to invert booleans.
  • Tab indentation must be used, not spaces.
  • Tables must be sequential where possible.
  • return must be used, not return nil.
  • Spaces must be on both sides of ...
  • Spacing must be between everything.
  • local foo = foo mustn't be used.
  • No unnecessary metamethods.
  • module mustn't be used.
  • select mustn't be used.

Garry's Mod

AddCSLuaFile()

ENT.Type = "anim"

ENT.Spawnable = true
ENT.AdminOnly = true
ENT.Editable = false

ENT.PrintName = "Entity Name"
ENT.Author = "MysteryPancake"
ENT.Purpose = "Entity purpose"
ENT.Instructions = "Entity instructions"
ENT.Category = "Entity category"
ENT.RenderGroup = RENDERGROUP_OPAQUE

XCode

  • The iOS requirement must be kept as low as possible.
  • Projects must include a complete icon set.
  • All build warnings must be enabled.
  • Warnings must be treated as errors.

Swift

  • Repeating arrays must be x: [Any] = Array(repeating: n, count: n), not x = [Any](repeating: n, count: n).
  • arc4random_uniform(max - min) + min must be used to get random numbers in a range.
  • UserDefaults.standard must be used to save data such as scores and progress.
  • arc4random and arc4random_uniform must be used to get random numbers.
  • .init mustn't be used when calling functions with specific arguments.
  • Variables must be private unless intended to be globally overridden.
  • Overridable classes must have as many final properties as possible.
  • Dictionaries must be x: [Any: Any] = [:], not x = [Any: Any]().
  • . must be used when calling functions with specific arguments.
  • Extensions and enums must be used to reduce namespace clutter.
  • "String \(foo)" must be used to join variables with strings.
  • Variables must use get, set, and didSet where possible.
  • Variables mustn't be type declared unless they're numbers.
  • Classes must be final unless intended to be overridden.
  • Generic SKAction.wait variables must be named delay.
  • struct must be used, not class, where possible.
  • Variables mustn't be above the level of internal.
  • Arrays must be x: [Any] = [], not x = [Any]().
  • Array and Dictionary must be used, not Set.
  • Double space indentation must be used, not tabs.
  • let must be used unless var is essential.
  • Ranges in for loops mustn't include spaces.
  • === and !== must be used where possible.
  • Unnecessary libraries mustn't be imported.
  • && must be used unless , is essential.
  • ? and ! variables mustn't be used.
  • Unused pointers must be set as nil.
  • DispatchQueue mustn't be used.
  • A newline mustn't be before }.
  • SKShapeNode mustn't be used.
  • Int must be used, not UInt.
  • & must be used for pointers.

C++

Classes must be indented like this:

class Person
{
private:
	string name;
public:
	void setName(string);
};

HTML

This template must be used:

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<title><Repository Name></title>
		<meta name="description" content="<Repository Description>">
		<meta name="keywords" content="<Repository, Key, Words>">
		<meta property="og:title" content="<Repository Title>">
		<meta property="og:type" content="website">
		<meta property="og:url" content="<WEBSITE_URL>">
		<meta property="og:image" content="<ICON_PATH>">
		<meta property="og:site_name" content="<Repository Title>">
		<meta property="og:description" content="<Repository Description>">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="stylesheet" type="text/css" href="style.css">
		<script src="script.js"></script>
	</head>
	<body>
		<span>Content</span>
	</body>
</html>

CSS

JavaScript

var index = array.indexOf(foo);
if (index !== -1) {
	array.splice(index, 1);
}

Unity

GitHub Pages