]> git.openstreetmap.org Git - rails.git/blob - CONTRIBUTING.md
Merge remote-tracking branch 'upstream/pull/2257'
[rails.git] / CONTRIBUTING.md
1 * https://www.ruby-lang.org/ - The homepage of Ruby which has more links and some great tutorials.
2 * http://rubyonrails.org/ - The homepage of Rails, also has links and tutorials
3
4 ## Coding style
5
6 We use [Rubocop](https://github.com/rubocop-hq/rubocop) (for ruby files)
7 and [ERB Lint](https://github.com/Shopify/erb-lint) (for erb templates)
8 to help maintain consistency in our code. You can run these utilities during
9 development to check that your code matches our guidelines:
10
11 ```
12 bundle exec rubocop
13 bundle exec erblint .
14 ```
15
16 ## Testing
17
18 Having a good suite of tests is very important to the stability and
19 maintainability of any code base. The tests in the Rails port code are
20 by no means complete, but they are extensive, and must continue to be
21 so with any new functionality which is written. Tests are also useful
22 in giving others confidence in the code you've written, and can
23 greatly speed up the process of merging in new code.
24
25 When hacking, you should:
26
27 * Write new tests to cover the new functionality you've added.
28 * Where appropriate, modify existing tests to reflect new or changed
29 functionality.
30 * Never comment out or remove a test just because it doesn't pass.
31
32 You can run the existing test suite with:
33
34 ```
35 bundle exec rake test
36 ```
37
38 You can view test coverage statistics by browsing the `coverage` directory.
39
40 The tests are automatically run on Pull Requests and other commits with the
41 results shown on [Travis CI](https://travis-ci.org/openstreetmap/openstreetmap-website).
42
43 ## Comments
44
45 Sometimes it's not apparent from the code itself what it does, or,
46 more importantly, **why** it does that. Good comments help your fellow
47 developers to read the code and satisfy themselves that it's doing the
48 right thing.
49
50 When hacking, you should:
51
52 * Comment your code - don't go overboard, but explain the bits which
53 might be difficult to understand what the code does, why it does it
54 and why it should be the way it is.
55 * Check existing comments to ensure that they are not misleading.
56
57 ## i18n
58
59 If you make a change that involve the locale files (in `config/locales`) then please
60 only submit changes to the `en.yml` file. The other files are updated via
61 [Translatewiki](https://translatewiki.net/wiki/Translating:OpenStreetMap) and should
62 not be included in your pull request.
63
64 ## Code Documentation
65
66 To generate the HTML documentation of the API/rails code, run the command
67
68 ```
69 rake doc:app
70 ```
71
72 ## Committing
73
74 When you submit patches, the project maintainer has to read them and
75 understand them. This is difficult enough at the best of times, and
76 misunderstanding patches can lead to them being more difficult to
77 merge. To help with this, when submitting you should:
78
79 * Split up large patches into smaller units of functionality.
80 * Keep your commit messages relevant to the changes in each individual
81 unit.
82
83 When writing commit messages please try and stick to the same style as
84 other commits, namely:
85
86 * A one line summary, starting with a capital and with no full stop.
87 * A blank line.
88 * Full description, as proper sentences with capitals and full stops.
89
90 For simple commits the one line summary is often enough and the body
91 of the commit message can be left out.
92
93 ## Sending the patches
94
95 If you have forked on GitHub then the best way to submit your patches is to
96 push your changes back to GitHub and then send a "pull request" on GitHub.
97
98 Otherwise you should either push your changes to a publicly visible git repository
99 and send the details to the [rails-dev](https://lists.openstreetmap.org/listinfo/rails-dev)
100 list or generate patches with `git format-patch` and send them to the
101 [rails-dev](https://lists.openstreetmap.org/listinfo/rails-dev) list.