|
| 1 | +# Contributing |
| 2 | + |
| 3 | +## Build |
| 4 | + |
| 5 | +### Sbt Projects |
| 6 | + |
| 7 | +- `scala-collection-compat` project (in the root directory): implementation of the compatibility library ; |
| 8 | +- In directory `scalafix/` there is an independent build containing the implementation of the migration tool. |
| 9 | + |
| 10 | +## Migration tool |
| 11 | + |
| 12 | +Several levels of contribution are possible! |
| 13 | + |
| 14 | +### Report a missing case |
| 15 | + |
| 16 | +Create an issue tagged with the |
| 17 | +[migration](https://github.com/scala/collection-strawman/labels/migration) label. |
| 18 | +Embrace `diff`s to describe differences between the standard collections and |
| 19 | +the strawman: |
| 20 | + |
| 21 | +~~~ diff |
| 22 | +- xs.toIterator |
| 23 | ++ xs.iterator() |
| 24 | +~~~ |
| 25 | + |
| 26 | +### Add a missing test case |
| 27 | + |
| 28 | +Even better, instead of providing a diff, you can directly add it as a test case! |
| 29 | + |
| 30 | +1. Fork this repository and create a separate branch; |
| 31 | + |
| 32 | +2. Add a file in the `scalafix/input/src/main/scala/fix/` directory with code |
| 33 | + that uses the standard collections: |
| 34 | + |
| 35 | +~~~ scala |
| 36 | +class toIteratorVsIterator(xs: Iterable[Int]) { |
| 37 | + xs.toIterator |
| 38 | +} |
| 39 | +~~~ |
| 40 | + |
| 41 | +3. Add a corresponding file in the `scalafix/output/src/main/scala/fix/` directory |
| 42 | + with the same code but using the strawman: |
| 43 | + |
| 44 | +~~~ scala |
| 45 | +import strawman.collection.Iterable |
| 46 | + |
| 47 | +class toIteratorVsIterator(xs: Iterable[Int]) { |
| 48 | + xs.iterator() |
| 49 | +} |
| 50 | +~~~ |
| 51 | + |
| 52 | +4. Check that your code example compiles |
| 53 | + - run sbt from the `scalafix/` directory |
| 54 | + and then run the following tasks `; input/compile ; output/compile`; |
| 55 | + |
| 56 | +5. Commit your changes, push your branch to your fork and create a pull request. |
| 57 | + |
| 58 | +Then maybe someone will take over and implement your use case… or maybe you will |
| 59 | +(see next section)! |
| 60 | + |
| 61 | +### Implement a missing case |
| 62 | + |
| 63 | +Even better, complete the migration tool implementation to support the missing case! |
| 64 | + |
| 65 | +After you have added the missing case (see previous section), run the following |
| 66 | +sbt task (with sbt started from the `scalafix/` directory) to run the |
| 67 | +migration tool on the input files and check whether the result matches the |
| 68 | +expected output files: |
| 69 | + |
| 70 | +~~~ |
| 71 | +> tests/test |
| 72 | +~~~ |
| 73 | + |
| 74 | +Fix the implementation of the rule (in the |
| 75 | +`rules/src/main/scala/fix/Scalacollectioncompat_v0.scala` file) until the |
| 76 | +tests are green. You can find more help about the scalafix API in its |
| 77 | +[documentation](https://scalacenter.github.io/scalafix/docs/rule-authors/setup). |
0 commit comments