diff --git a/Rguide.md b/Rguide.md index 786230c..774b57d 100644 --- a/Rguide.md +++ b/Rguide.md @@ -15,8 +15,10 @@ Google uses the [styler](https://github.com/r-lib/styler) package on every checked in file to ensure code consistency and help reviewers focus on more important issues. + * TOC {:toc} + ## Syntax diff --git a/csharpguide.md b/csharpguide.md index 440c17d..cfbe74d 100644 --- a/csharpguide.md +++ b/csharpguide.md @@ -4,8 +4,10 @@ This style guide is for C# code developed internally at Google, and is the default style for C# code at Google. It makes stylistic choices that conform to other languages at Google, such as Google C++ style and Google Java style. + * TOC {:toc} + ## Formatting guidelines diff --git a/haskellguide.md b/haskellguide.md index 09e3672..57ccfc8 100644 --- a/haskellguide.md +++ b/haskellguide.md @@ -2,8 +2,10 @@ Revision 1.01 + * TOC {:toc} + @@ -19,7 +21,8 @@ style are generally closely tied to the semantics of the code you wish to convey. As such, this guide tends to be somewhat less prescriptive than most, as there are just fewer arbitrary choices to make when coding Haskell. -Open-source projects developed by Google should conform to the requirements in this guide. +Open-source projects developed by Google should conform to the requirements in +this guide. @@ -83,8 +86,7 @@ explicitly naming them in the export list would be counter-productive. ### Imports * Imports may be split up into groups separated by a single newline. -* Recommended: Split imports into two groups: external and - internal modules. +* Recommended: Split imports into two groups: external and internal modules. * Within each group, imports must be alphabetized by full module name. * Imports can either be qualified or for specific elements. It is okay to have both. @@ -141,13 +143,12 @@ GHC options and `LANGUAGE` pragmas go at the very top of the file. The `OPTIONS_GHC` directive should only be used for specific options that relate to the source file, such as `-fno-warn-orphans` for test code. General -compilation options, like `-O2`, belong in -the `.cabal` file. +compilation options, like `-O2`, belong in the `.cabal` file. Features enabled by the `LANGUAGE` pragma should always be listed in each source -file that needs them, and never turned on globally via flags in the -the `.cabal` file. This is so future -developers know what language extensions are in effect when reading the code. +file that needs them, and never turned on globally via flags in the the `.cabal` +file. This is so future developers know what language extensions are in effect +when reading the code. `INLINE`, `INLINEABLE`, and similar pragmas should only be used when you've tested that they actually improve speed in cases that you care about. When used, diff --git a/htmlcssguide.md b/htmlcssguide.md index 6ea96f4..40d4a98 100644 --- a/htmlcssguide.md +++ b/htmlcssguide.md @@ -2,8 +2,10 @@ # Google HTML/CSS Style Guide + * TOC {:toc} +
@@ -1039,8 +1041,8 @@ color: #ebc; Avoid using `!important` declarations. These declarations break the natural cascade of CSS and make it difficult to -reason about and compose styles. Use -[selector specificity] to override properties instead. +reason about and compose styles. Use [selector specificity] to override +properties instead. [selector specificity]: https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity diff --git a/jsoncguide.md b/jsoncguide.md index 5a17ed3..ec83ba8 100644 --- a/jsoncguide.md +++ b/jsoncguide.md @@ -2,8 +2,10 @@ Revision 0.9 + * TOC {:toc} + @@ -131,8 +133,9 @@ Choose meaningful property names. Property names must conform to the following guidelines: * Property names should be meaningful names with defined semantics. -* Property names must be [lower - camel-cased](https://en.wikipedia.org/wiki/Camel_case), ASCII strings. +* Property names must be + [lower camel-cased](https://en.wikipedia.org/wiki/Camel_case), ASCII + strings. * The first character must be a letter, an underscore (`_`) or a dollar sign (`$`). * Subsequent characters can be a letter, a digit, an underscore, or a dollar @@ -393,8 +396,8 @@ easily parsed. Dates should be formatted as recommended by RFC 3339. -Dates should be strings formatted as recommended by [RFC -3339](https://www.ietf.org/rfc/rfc3339.txt). +Dates should be strings formatted as recommended by +[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt). ```json { @@ -408,8 +411,8 @@ Dates should be strings formatted as recommended by [RFC Time durations should be formatted as recommended by ISO 8601. -Time duration values should be strings formatted as recommended by [ISO -8601](https://en.wikipedia.org/wiki/ISO_8601#Durations). +Time duration values should be strings formatted as recommended by +[ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Durations). ```json { @@ -425,9 +428,9 @@ Time duration values should be strings formatted as recommended by [ISO Latitudes/Longitudes should be formatted as recommended by ISO 6709. -Latitude/Longitude should be strings formatted as recommended by [ISO -6709](https://en.wikipedia.org/wiki/ISO_6709). Furthermore, they should favor -the ±DD.DDDD±DDD.DDDD degrees format. +Latitude/Longitude should be strings formatted as recommended by +[ISO 6709](https://en.wikipedia.org/wiki/ISO_6709). Furthermore, they should +favor the ±DD.DDDD±DDD.DDDD degrees format. ```json { @@ -519,7 +522,7 @@ The top-level of the JSON object may contain the following properties. ### apiVersion -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: - Represents the desired version of the service API in a request, and the version @@ -537,7 +540,7 @@ Example: ### context -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: - Client sets this value and server echoes data in the response. This is useful in @@ -599,7 +602,7 @@ function handleResponse(response) { ### id -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: - A server supplied identifier for the response (regardless of whether the @@ -616,7 +619,7 @@ Example: ### method -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: - Represents the operation to perform, or that was performed, on the data. In the @@ -641,7 +644,7 @@ operation to perform on the `params` property: ### params -Property Value Type: `object`\ +Property Value Type: `object` \ Parent: - This object serves as a map of input parameters to send to an RPC request. It @@ -665,7 +668,7 @@ Example: ### data -Property Value Type: `object`\ +Property Value Type: `object` \ Parent: - Container for all the data from a response. This property itself has many @@ -678,7 +681,7 @@ present, the `error` object takes precedence. ### error -Property Value Type: `object`\ +Property Value Type: `object` \ Parent: - Indicates that an error has occurred, with details about the error. The error @@ -714,7 +717,7 @@ The `data` property of the JSON object may contain the following properties. ### data.kind -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: `data` The `kind` property serves as a guide to what type of information this @@ -735,7 +738,7 @@ Example: ### data.fields -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: `data` Represents the fields present in the response when doing a partial GET, or the @@ -759,7 +762,7 @@ Example: ### data.etag -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: `data` Represents the etag for the response. Details about ETags in the GData APIs can @@ -776,7 +779,7 @@ Example: ### data.id -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: `data` A globally unique string used to reference the object. The specific details of @@ -792,13 +795,13 @@ Example: ### data.lang -Property Value Type: `string` (formatted as specified in BCP 47)\ +Property Value Type: `string` (formatted as specified in BCP 47) \ Parent: `data` (or any child element) Indicates the language of the rest of the properties in this object. This property mimics HTML's `lang` property and XML's `xml:lang` properties. The -value should be a language value as defined in [BCP -47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). If a single JSON object +value should be a language value as defined in +[BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). If a single JSON object contains data in multiple languages, the service is responsible for developing and documenting an appropriate location for the `lang` property. @@ -819,7 +822,7 @@ Example: ### data.updated -Property Value Type: `string` (formatted as specified in RFC 3339)\ +Property Value Type: `string` (formatted as specified in RFC 3339) \ Parent: `data` Indicates the last date/time ([RFC 3339](https://www.ietf.org/rfc/rfc3339.txt)) @@ -835,7 +838,7 @@ Example: ### data.deleted -Property Value Type: `boolean`\ +Property Value Type: `boolean` \ Parent: `data` (or any child element) A marker element, that, when present, indicates the containing entry is deleted. @@ -858,7 +861,7 @@ Example: ### data.items -Property Value Type: `array`\ +Property Value Type: `array` \ Parent: `data` The property name `items` is reserved to represent an array of items (for @@ -895,9 +898,9 @@ The paging properties below allow for various styles of paging, including: * Previous/Next paging - Allows users to move forward and backward through a list, one page at a time. The `nextLink` and `previousLink` properties - (described in the [Reserved Property Names for - Links](#Reserved_Property_Names_for_Links) section below) are used for this - style of paging. + (described in the + [Reserved Property Names for Links](#Reserved_Property_Names_for_Links) + section below) are used for this style of paging. * Index-based paging - Allows users to jump directly to a specific item position within a list of items. For example, to load 10 items starting at item 200, the developer may point the user to a URL with the query string @@ -917,7 +920,7 @@ the end of this guide. ### data.currentItemCount -Property Value Type: `integer`\ +Property Value Type: `integer` \ Parent: `data` The number of items in this result set. Should be equivalent to `items.length`, @@ -944,7 +947,7 @@ Example: ### data.itemsPerPage -Property Value Type: `integer`\ +Property Value Type: `integer` \ Parent: `data` The number of items in the result. This is not necessarily the size of the @@ -966,7 +969,7 @@ Example: ### data.startIndex -Property Value Type: `integer`\ +Property Value Type: `integer` \ Parent: `data` The index of the first item in `data.items`. For consistency, `startIndex` @@ -988,7 +991,7 @@ Example: ### data.totalItems -Property Value Type: `integer`\ +Property Value Type: `integer` \ Parent: `data` The total number of items available in this set. For example, if a user has 100 @@ -1009,7 +1012,7 @@ Example: ### data.pagingLinkTemplate -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: `data` A URI template indicating how users can calculate subsequent paging links. The @@ -1030,7 +1033,7 @@ Example: ### data.pageIndex -Property Value Type: `integer`\ +Property Value Type: `integer` \ Parent: `data` The index of the current page of items. For consistency, `pageIndex` should be @@ -1052,7 +1055,7 @@ Example: ### data.totalPages -Property Value Type: `integer`\ +Property Value Type: `integer` \ Parent: `data` The total number of pages in the result set. `totalPages` can also be calculated @@ -1085,7 +1088,7 @@ references to other resources. There are two forms of link properties: ### data.self / data.selfLink -Property Value Type: `object` / `string`\ +Property Value Type: `object` / `string` \ Parent: `data` The self link can be used to retrieve the item's data. For example, in a list of @@ -1107,7 +1110,7 @@ Example: ### data.edit / data.editLink -Property Value Type: `object` / `string`\ +Property Value Type: `object` / `string` \ Parent: `data` The edit link indicates where a user can send update or delete requests. This is @@ -1129,7 +1132,7 @@ Example: ### data.next / data.nextLink -Property Value Type: `object` / `string`\ +Property Value Type: `object` / `string` \ Parent: `data` The next link indicates how more data can be retrieved. It points to the @@ -1152,7 +1155,7 @@ Example: ### data.previous / data.previousLink -Property Value Type: `object` / `string`\ +Property Value Type: `object` / `string` \ Parent: `data` The previous link indicates how more data can be retrieved. It points to the @@ -1181,7 +1184,7 @@ The `error` property of the JSON object may contain the following properties. ### error.code -Property Value Type: `integer`\ +Property Value Type: `integer` \ Parent: `error` Represents the code for this error. This property value will usually represent @@ -1202,7 +1205,7 @@ Example: ### error.message -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: `error` A human readable message providing more details about the error. If there are @@ -1222,7 +1225,7 @@ Example: ### error.errors -Property Value Type: `array`\ +Property Value Type: `array` \ Parent: `error` Container for any additional information regarding the error. If the service @@ -1239,7 +1242,7 @@ Example: ### error.errors\[\].domain -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: `error.errors` Unique identifier for the service raising this error. This helps distinguish @@ -1260,7 +1263,7 @@ Example: ### error.errors\[\].reason -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: `error.errors` Unique identifier for this error. Different from the `error.code` property in @@ -1280,7 +1283,7 @@ Example: ### error.errors\[\].message -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: `error.errors` A human readable message providing more details about the error. If there is @@ -1302,7 +1305,7 @@ Example: ### error.errors\[\].location -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: `error.errors` The location of the error (the interpretation of its value depends on @@ -1322,7 +1325,7 @@ Example: ### error.errors\[\].locationType -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: `error.errors` Indicates how the `location` property should be interpreted. @@ -1341,7 +1344,7 @@ Example: ### error.errors\[\].extendedHelp -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: `error.errors` A URI for a help text that might shed some more light on the error. @@ -1360,7 +1363,7 @@ Example: ### error.errors\[\].sendReport -Property Value Type: `string`\ +Property Value Type: `string` \ Parent: `error.errors` A URI for a report form used by the service to collect data about the error @@ -1573,8 +1576,8 @@ The words below are reserved by the JavaScript language and cannot be referred to using dot notation. The list represents best knowledge of keywords at this time; the list may change or vary based on your specific execution environment. -From the [ECMAScript Language Specification 5th -Edition](https://www.ecma-international.org/publications-and-standards/standards/ecma-262/): +From the +[ECMAScript Language Specification 5th Edition](https://www.ecma-international.org/publications-and-standards/standards/ecma-262/): diff --git a/lispguide.md b/lispguide.md index 18d32de..4ad130e 100644 --- a/lispguide.md +++ b/lispguide.md @@ -13,8 +13,10 @@ mistakes in this document, you may file bugs in the "[Lisp]" in the issue title since the repository contains Style Guides for several languages. + * TOC {:toc} + ### References @@ -1038,7 +1040,9 @@ assignments. ### Assertions and Conditions -Use `assert`, `check-type`, and `etypecase` to detect internal bugs only, and use them liberally. +Use `assert`, `check-type`, and `etypecase` to detect internal bugs only, and +use them liberally. + - Prefer `etypecase` over `typecase` - Use `error` to check input from a file. - If a function signals an error, document it in its contract. @@ -1053,14 +1057,13 @@ Use `assert`, `check-type`, and `etypecase` to detect internal bugs only, and us - Never clean up by resignaling. - Never return a condition or error value, signal it with ERROR instead. -Use `assert` to detect internal bugs ONLY. -Code should `assert` invariants whose failure indicates that the software is -itself broken. Incorrect input should be handled properly at runtime, and must -not cause an assertion violation. The audience for an `assert` failure is a -developer. Do not use the data-form and argument-form in `assert` to specify a -condition to signal. It's fine to use them to print out a message for debugging -purposes (and since it's only for debugging, there's no issue of -internationalization). +Use `assert` to detect internal bugs ONLY. Code should `assert` invariants whose +failure indicates that the software is itself broken. Incorrect input should be +handled properly at runtime, and must not cause an assertion violation. The +audience for an `assert` failure is a developer. Do not use the data-form and +argument-form in `assert` to specify a condition to signal. It's fine to use +them to print out a message for debugging purposes (and since it's only for +debugging, there's no issue of internationalization). `check-type`, `etypecase` are also forms of assertion. When one of these fails, that's a detected bug. Prefer `check-type` over `(declare (type ...))` for the @@ -1170,7 +1173,8 @@ Scott McKay puts it: Use appropriate declarations in internal low-level functions where these declarations are used for optimization. When you do, however, see our -recommendations for [Unsafe Operations](lispprogrammingguide.md#unsafe-operations). +recommendations for +[Unsafe Operations](lispprogrammingguide.md#unsafe-operations). ## Meta-language guidelines @@ -1734,8 +1738,9 @@ or control to leak to attackers. - Use `:START` and `:END` arguments to `string=` or `string-equal` instead of using `subseq`. - Use `zerop`, `plusp`, or `minusp` instead of comparing to `0` or `0.0`. -- See also [Comparison Operators](lispprogrammingguide.md#comparison-operators) in - the programming guide for proper usage. +- See also + [Comparison Operators](lispprogrammingguide.md#comparison-operators) in the + programming guide for proper usage. When choosing between `eq` and `eql`, you should use `eql` unless you are writing performance-critical low-level code. `eql` reduces the opportunity for a diff --git a/lispprogrammingguide.md b/lispprogrammingguide.md index 7932626..b22db92 100644 --- a/lispprogrammingguide.md +++ b/lispprogrammingguide.md @@ -8,8 +8,10 @@ style, but that are important to new Lisp Programmers. The three main topics covered include common optimization techniques, as well as common pitfalls for new Lisp programmers. + * TOC {:toc} + ## Optimization @@ -296,8 +298,8 @@ none~; ~S~; ~S and ~S~:;~@{~#[~; and~] ~S~^ ,~}~]."` - You should the appropriate predicates when comparing objects. - Also see the notes for - [Comparison Operators](lispguide.md#comparison-operators) in the style - guide for style rules. + [Comparison Operators](lispguide.md#comparison-operators) in the style guide + for style rules. Lisp provides four general equality predicates: `EQ`, `EQL`, `EQUAL`, and `EQUALP`, which subtly vary in semantics. Additionally, Lisp provides the diff --git a/objcguide.md b/objcguide.md index 23b4a44..e0bfd22 100644 --- a/objcguide.md +++ b/objcguide.md @@ -5,22 +5,24 @@ > is one of the primary development languages for applications on Apple > platforms. > -> Apple has already written a very good, and widely accepted, [Cocoa Coding -> Guidelines](https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html) +> Apple has already written a very good, and widely accepted, +> [Cocoa Coding Guidelines](https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html) > for Objective-C. Please read it in addition to this guide. > > The purpose of this document is to describe the Objective-C (and > Objective-C++) coding guidelines and practices. These guidelines have evolved -> and been proven over time on other projects and teams. -> Open-source projects developed by Google conform to the requirements in this guide. +> and been proven over time on other projects and teams. Open-source projects +> developed by Google conform to the requirements in this guide. > > Note that this guide is not an Objective-C tutorial. We assume that the reader > is familiar with the language. If you are new to Objective-C or need a -> refresher, please read [Programming with -> Objective-C](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html). +> refresher, please read +> [Programming with Objective-C](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html). + * TOC {:toc} + ## Principles @@ -170,8 +172,7 @@ An example source file, demonstrating the correct commenting and spacing for the ## Naming Names should be as descriptive as possible, within reason. Follow standard -[Objective-C naming -rules](https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html). +[Objective-C naming rules](https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html). Avoid non-standard abbreviations (including non-standard acronyms and initialisms). Don't worry about saving horizontal space as it is far more @@ -439,8 +440,8 @@ NSEnumerator *enumerator = [frogs reverseObjectEnumerator]; // GOOD. NSEnumerator *enumerator = frogs.reverseObjectEnumerator; // AVOID. ``` -See [Apple's Guide to Naming -Methods](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingMethods.html#//apple_ref/doc/uid/20001282-BCIGIJJF) +See +[Apple's Guide to Naming Methods](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingMethods.html#//apple_ref/doc/uid/20001282-BCIGIJJF) for more details on Objective-C naming. These guidelines are for Objective-C methods only. C++ method names continue to @@ -620,10 +621,10 @@ void CallWithAFoo(Foo *foo); ### Method Declarations -As shown in the [example](#Example), the recommended order -for declarations in an `@interface` declaration are: properties, class methods, -initializers, and then finally instance methods. The class methods section -should begin with any convenience constructors. +As shown in the [example](#Example), the recommended order for declarations in +an `@interface` declaration are: properties, class methods, initializers, and +then finally instance methods. The class methods section should begin with any +convenience constructors. @@ -661,8 +662,8 @@ objects are automatically initialized to `nil`, so explicit initialization to `nil` is not required for those common cases. However, automatic initialization does *not* occur for many Objective-C pointer types, including object pointers declared with the `__unsafe_unretained` ownership qualifier and CoreFoundation -object pointer types. When in doubt, prefer to initialize all Objective-C -local variables. +object pointer types. When in doubt, prefer to initialize all Objective-C local +variables. ### Static Variables @@ -718,8 +719,8 @@ NS_ENUM will be more appropriate. Be aware that types long, NSInteger, NSUInteger and CGFloat have sizes that differ in 32- and 64-bit builds. Their use is appropriate when matching system -interfaces but should be avoided when dealing with APIs that -require exact sizing, e.g., proto APIs. +interfaces but should be avoided when dealing with APIs that require exact +sizing, e.g., proto APIs. @@ -755,8 +756,8 @@ warnings. Since all Google iOS projects are now targeting only 64-bit runtime, `CGFloat` constants may omit the suffix (use `double` values). However, teams may choose to continue using `float` numbers for legacy code consistency, until they -eventually migrate to `double` values everywhere. Avoid a mixture of `float` -and `double` values in the same code. +eventually migrate to `double` values everywhere. Avoid a mixture of `float` and +`double` values in the same code. @@ -806,15 +807,15 @@ will need to understand your code. Be generous—the next one may be you! A file may optionally start with a description of its contents. Every file may contain the following items, in order - * License boilerplate if necessary. Choose the appropriate boilerplate for the + +* License boilerplate if necessary. Choose the appropriate boilerplate for the license used by the project. - * A basic description of the contents of the file if necessary. +* A basic description of the contents of the file if necessary. If you make significant changes to a file with an author line, consider deleting the author line since revision history already provides a more detailed and accurate record of authorship. - ### Declaration Comments @@ -825,7 +826,6 @@ comment describing its purpose and how it fits into the larger picture. Comments should be used to document classes, properties, ivars, functions, categories, protocol declarations, and enums. - ```objectivec @@ -848,10 +848,9 @@ categories, protocol declarations, and enums. ``` [Doxygen](https://doxygen.nl)-style comments are encouraged for interfaces as -they are parsed by Xcode -to display formatted documentation. There is a wide variety of -[Doxygen commands](https://www.doxygen.nl/manual/commands.html); -use them consistently within a project. +they are parsed by Xcode to display formatted documentation. There is a wide +variety of [Doxygen commands](https://www.doxygen.nl/manual/commands.html); use +them consistently within a project. If you have already described an interface in detail in the comments at the top of your file, feel free to simply state, "See comment at top of file for a @@ -877,10 +876,10 @@ Declaration comments explain how a method or function is used. Comments explaining how a method or function is implemented should be with the implementation rather than with the declaration. -Declaration comments may be omitted on test case classes and test methods -if comments would communicate no additional information beyond the method's -name. Utility methods in tests or test-specific classes (such as helpers) should -be commented. +Declaration comments may be omitted on test case classes and test methods if +comments would communicate no additional information beyond the method's name. +Utility methods in tests or test-specific classes (such as helpers) should be +commented. @@ -918,8 +917,8 @@ line them up. ### Disambiguating Symbols Where needed to avoid ambiguity, use backticks or vertical bars to quote -variable names and symbols in comments in preference to using quotation marks -or naming the symbols inline. +variable names and symbols in comments in preference to using quotation marks or +naming the symbols inline. In Doxygen-style comments, prefer demarcating symbols with a monospace text command, such as [`@c`](https://www.doxygen.nl/manual/commands.html#cmdc). @@ -1062,9 +1061,9 @@ practices. Do not define macros that appear to be C or Objective-C keywords. Avoid macros that expand to unbalanced C or Objective-C constructs. Avoid macros that introduce scope, or may obscure the capturing of values in blocks. -Avoid macros that generate class, property, or method definitions in -headers to be used as public API. These only make the code hard to -understand, and the language already has better ways of doing this. +Avoid macros that generate class, property, or method definitions in headers to +be used as public API. These only make the code hard to understand, and the +language already has better ways of doing this. Avoid macros that generate method implementations, or that generate declarations of variables that are later used outside of the macro. Macros shouldn't make @@ -1083,9 +1082,9 @@ ARRAY_ADDER(NSString) { } ``` -Examples of acceptable macro use include assertion and debug logging macros -that are conditionally compiled based on build settings—often, these are -not compiled into release builds. +Examples of acceptable macro use include assertion and debug logging macros that +are conditionally compiled based on build settings—often, these are not compiled +into release builds. ### `nullptr` vs. `NULL` @@ -1225,8 +1224,8 @@ Convenience class factory methods for creating instances may precede the Don't initialize instance variables to `0` or `nil` in the `init` method; doing so is redundant. -All instance variables for a newly allocated object are [initialized -to](https://developer.apple.com/library/mac/documentation/General/Conceptual/CocoaEncyclopedia/ObjectAllocation/ObjectAllocation.html) +All instance variables for a newly allocated object are +[initialized to](https://developer.apple.com/library/mac/documentation/General/Conceptual/CocoaEncyclopedia/ObjectAllocation/ObjectAllocation.html) `0` (except for isa), so don't clutter up the init method by re-initializing variables to `0` or `nil`. @@ -1281,8 +1280,8 @@ prevent subclasses from unintentionally overriding them. `#import` Objective-C and Objective-C++ headers, and `#include` C/C++ headers. -C/C++ headers include other C/C++ headers using `#include`. Using `#import` -on C/C++ headers prevents future inclusions using `#include` and could result in +C/C++ headers include other C/C++ headers using `#include`. Using `#import` on +C/C++ headers prevents future inclusions using `#include` and could result in unintended compilation behavior. C/C++ headers should provide their own `#define` guard. @@ -1295,9 +1294,9 @@ The standard order for header inclusion is the related header, operating system headers, language library headers, and finally groups of headers for other dependencies. -The related header precedes others to ensure it has no hidden dependencies. -For implementation files the related header is the header file. -For test files the related header is the header containing the tested interface. +The related header precedes others to ensure it has no hidden dependencies. For +implementation files the related header is the header file. For test files the +related header is the header containing the tested interface. Separate each non-empty group of includes with one blank line. Within each group the includes should be ordered alphabetically. @@ -1477,8 +1476,8 @@ leading to slower execution and substantial increases in binary size. ### Mutables, Copies and Ownership -For [Foundation and other hierarchies containing both immutable and mutable -subclasses](https://developer.apple.com/library/archive/documentation/General/Conceptual/CocoaEncyclopedia/ObjectMutability/ObjectMutability.html) +For +[Foundation and other hierarchies containing both immutable and mutable subclasses](https://developer.apple.com/library/archive/documentation/General/Conceptual/CocoaEncyclopedia/ObjectMutability/ObjectMutability.html) a mutable subclass may be substituted for an immutable so long as the immutable's contract is honored. @@ -1545,9 +1544,8 @@ initializers and setters Synthesized accessors should use the `copy` keyword to ensure the generated code matches these expectations. -NOTE: [The `copy` property keyword only affects the synthesized setter and has -no effect on -getters](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocProperties.html#//apple_ref/doc/uid/TP30001163-CH17-SW27). +NOTE: +[The `copy` property keyword only affects the synthesized setter and has no effect on getters](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocProperties.html#//apple_ref/doc/uid/TP30001163-CH17-SW27). Since property keywords have no effect on direct ivar access, custom accessors must implement the same copy semantics. @@ -1674,8 +1672,7 @@ Don't `@throw` Objective-C exceptions, but you should be prepared to catch them from third-party or OS calls. This follows the recommendation to use error objects for error delivery in -[Apple's Introduction to Exception Programming Topics for -Cocoa](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Exceptions/Exceptions.html). +[Apple's Introduction to Exception Programming Topics for Cocoa](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Exceptions/Exceptions.html). We do compile with `-fobjc-exceptions` (mainly so we get `@synchronized`), but we don't `@throw`. Uses of `@try`, `@catch`, and `@finally` are allowed when @@ -1687,8 +1684,8 @@ document exactly which methods you expect to throw. ### `nil` Checks Avoid `nil` pointer checks that exist only to prevent sending messages to `nil`. -Sending a message to `nil` [reliably -returns](http://www.sealiesoftware.com/blog/archive/2012/2/29/objc_explain_return_value_of_message_to_nil.html) +Sending a message to `nil` +[reliably returns](http://www.sealiesoftware.com/blog/archive/2012/2/29/objc_explain_return_value_of_message_to_nil.html) `nil` as a pointer, zero as an integer or floating-point value, structs initialized to `0`, and `_Complex` values equal to `{0, 0}`. @@ -1761,22 +1758,23 @@ NSArray