Skip to content

Coding Style

Larry Reid edited this page Jun 5, 2017 · 5 revisions

Ruby

We don't believe in arguing that one style is better than another. We do believe in consistent code formatting. We believe in letting the editor do the code formatting. We don't believe in eliminating all the warnings from the editor.

We follow the Ruby style guidelines. Where the style guideline allows variation, we prefer the following:

  • When you have to split a line, indent the split line one additional level, rather than aligning arguments. We prefer this because it causes fewer line splits when you have long, descriptive method names
  • Prefer double-quoted strings to single-quoted strings. We prefer this option because it's easier to use contractions in strings, and easier to add Ruby string interpolation

The .rubyocop.yml to achieve the above is:

Style/StringLiterals:
  EnforcedStyle: double_quotes
  SupportedStyles:
    - single_quotes
    - double_quotes
  # If true, strings which span multiple lines using \ for continuation must
  # use the same type of quotes on each line.
  ConsistentQuotesInMultiline: false

Style/AlignParameters:
  # Alignment of parameters in multi-line method calls.
  #
  # The `with_first_parameter` style aligns the following lines along the same
  # column as the first parameter.
  #
  #     method_call(a,
  #                 b)
  #
  # The `with_fixed_indentation` style aligns the following lines with one
  # level of indentation relative to the start of the line with the method call.
  #
  #     method_call(a,
  #       b)
  EnforcedStyle: with_fixed_indentation
  SupportedStyles:
    - with_first_parameter
    - with_fixed_indentation
  # By default, the indentation width from Style/IndentationWidth is used
  # But it can be overridden by setting this parameter
  IndentationWidth: ~

Put the above in .rubyocop.yml in the root directory of the project.

In Atom, you need to install the following packages:

  • linter-rubocop
  • rubocop-auto-correct
  • Others?

The above will install linter, linter-ui-default, and others. You will be prompted to confirm the install of the dependencies.

You need to install Rubocop for the above:

gem install rubocop

Becuase Rubocop is a gem, you'll also need to first install Ruby on your development platform, AKA the computer and operating system that runs Atom.

Javascript

TBD

CSS

CSS is described elsewhere in this wiki.

Home

[Collaborating on Projects](Using GitHub to Collaborate on We Enhance IT Projects)

Clone this wiki locally