Skip to content

Latest commit

 

History

History
100 lines (62 loc) · 7.51 KB

CONTRIBUTING.md

File metadata and controls

100 lines (62 loc) · 7.51 KB

How to Contribute

First of all, thank you for wanting to contribute to FakeItEasy Analyzers! We really appreciate all the awesome support we get from our community. We want to keep it as easy as possible for you to contribute changes that make the FakeItEasy Analyzers better for you. There are a few guidelines that we need contributors to follow so that we can all work together happily.

Preparation

Before starting work on a functional change, i.e. a new feature, a change to an existing feature or a bug, please ensure an issue has been raised. Indicate your intention to work on the issue by writing a comment against it. This will prevent duplication of effort. If the change is non-trivial, it's usually best to propose a design in the issue comments.

It is not necessary to raise an issue for non-functional changes, e.g. refactoring, adding tests, reformatting code, documentation, updating packages, etc.

Tests

Changes in analyzer functionality (new features, changed behavior, or bug fixes) should be described by xUnit.net unit tests in the FakeItEasy.Analyzer.CSharp.Tests and FakeItEasy.Analyzer.VisualBasic.Testsprojects. There should be a high level of test coverage.

Spaces not Tabs

Pull requests containing tabs will not be accepted. Make sure you set your editor to replace tabs with spaces. Indents for all file types should be 4 characters wide with the exception of JSON which should have indents 2 characters wide.

Line Endings

The repository is configured to preserve line endings both on checkout and commit (the equivalent of autocrlf set to false). This means you are responsible for line endings. We recommend that you configure your diff viewer so that it does not ignore line endings. Any wall of pink pull requests will not be accepted.

Line Width

Try to keep lines of code no longer than 160 characters wide. This isn't a strict rule. Occasionally a line of code can be more readable if allowed to spill over slightly. A good way to remember this rule is to use the 'Column Guides' feature of the Productivity Power Tools 2012 extension for Visual Studio.

Coding Style

Try to keep your coding style in line with the existing code. It might not exactly match your preferred style but it's better to keep things consistent. Coding style compliance is enforced through analysis on each build. Any StyleCop.Analyzers settings changes or suppressions must be clearly justified.

String Formatting

Unless there is a compelling reason not to, for example when serializing data to be parsed later, use the current culture when formatting strings. When string formatting methods have an overload that implicitly uses the current culture, opt to use it instead of specifying the culture explicitly.

Code Analysis

Try to avoid introducing new code analysis warnings. Currently the codebase is free of warnings, and we would like to avoid the addition of new warnings. Any code analysis rule changes or suppressions must be clearly justified.

Resharper Artifacts

Please do not add Resharper suppressions to code using comments. You may tweak your local Resharper settings but do not commit these to the repo.

When configuring e.g. inspection severity, you can choose where to save the settings:

  • Solution "FakeItEasy.Analyzers" personal
  • Solution "FakeItEasy.Analyzers" team-shared
  • This computer

You should pick either the "personal" or "this computer" option.

Making Changes

FakeItEasy.Analyzers uses the git branching model known as GitHub flow. As such, all development must be performed on a "feature branch" created from the main development branch, which is called master. To submit a change:

  1. Fork the FakeItEasy.Analyzers repository on GitHub
  2. Clone your fork locally
  3. Configure the upstream repo (git remote add upstream git://github.com/FakeItEasy/FakeItEasy.Analyzers.git)
  4. Create a local branch (git checkout -b my-branch master)
  5. Work on your feature
  6. Rebase if required (see below)
  7. Run code analysis on the solution to ensure you have not introduced any violations
  8. Ensure the build succeeds (see 'How to build')
  9. Push the branch up to GitHub (git push origin my-branch)
  10. Send a pull request on GitHub

You should never work directly on the master branch and you should never send a pull request from the master branch - always from a feature branch. The reasons for this are detailed below.

Handling Updates from upstream/master

While you're working away in your branch it's quite possible that your upstream/master (most likely the canonical FakeItEasy.Analyzers version) may be updated. If this happens you should:

  1. Stash any un-committed changes you need to
  2. git checkout master
  3. git pull upstream master
  4. git checkout my-branch
  5. git rebase master my-branch
  6. git push origin master - (optional) this makes sure your remote master branch is up to date
  7. if you previously pushed your branch to your origin, you need to force push the rebased branch - git push origin my-branch -f

This ensures that your history is "clean" i.e. you have one branch off from master followed by your changes in a straight line. Failing to do this ends up with several "messy" merges in your history, which we don't want. This is the reason why you should always work in a branch and you should never be working in, or sending pull requests from, master.

If you're working on a long running feature then you may want to do this quite often, rather than run the risk of potential merge issues further down the line.

Sending a Pull Request

While working on your feature you may well create several branches, which is fine, but before you send a pull request you should ensure that you have rebased back to a single feature branch. We care about your commits and we care about your feature branch but we don't care about how many or which branches you created while you were working on it. 😄

When you're ready to go you should confirm that you are up to date and rebased with upstream/master (see "Handling Updates from upstream/master" above) and then:

  1. git push origin my-branch
  2. Send a pull request in GitHub, selecting the following dropdown values:
Dropdown Value
base fork FakeItEasy/FakeItEasy.Analyzers
base master
head fork {your fork} (e.g. {your username}/FakeItEasy.Analyzers)
compare my-branch

The pull request should include a description starting with "Fixes #123." (using the real issue number, of course) if it fixes an issue. If there's no issue, be sure to clearly explain the intent of the change.