]> git.openstreetmap.org Git - rails.git/blob - CONTRIBUTING.md
Localisation updates from https://translatewiki.net.
[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 ## Code Documentation
58
59 To generate the HTML documentation of the API/rails code, run the command
60
61 ```
62 rake doc:app
63 ```
64
65 ## Committing
66
67 When you submit patches, the project maintainer has to read them and
68 understand them. This is difficult enough at the best of times, and
69 misunderstanding patches can lead to them being more difficult to
70 merge. To help with this, when submitting you should:
71
72 * Split up large patches into smaller units of functionality.
73 * Keep your commit messages relevant to the changes in each individual
74 unit.
75
76 When writing commit messages please try and stick to the same style as
77 other commits, namely:
78
79 * A one line summary, starting with a capital and with no full stop.
80 * A blank line.
81 * Full description, as proper sentences with capitals and full stops.
82
83 For simple commits the one line summary is often enough and the body
84 of the commit message can be left out.
85
86 ## Sending the patches
87
88 If you have forked on GitHub then the best way to submit your patches is to
89 push your changes back to GitHub and then send a "pull request" on GitHub.
90
91 Otherwise you should either push your changes to a publicly visible git repository
92 and send the details to the [rails-dev](https://lists.openstreetmap.org/listinfo/rails-dev)
93 list or generate patches with `git format-patch` and send them to the
94 [rails-dev](https://lists.openstreetmap.org/listinfo/rails-dev) list.