Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add comments for crystal analyzer 1.3 #2357

Merged
merged 4 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions analyzer-comments/crystal/darts/hypot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Pow

Using `pow`, `sqrt` or `**` is totally valid and can be necessary in many situations.
However when we want a distance in Cartesian space we can use the [`hypot` method][hypot] which returns the hypotenuse of a right angle triangle with sides x and y.

```crystal
# Rather than:
Math.sqrt(number ** 2 + another_number ** 2)

# Consider:
Math.hypot(number, another_number)
```

[hypot]: https://crystal-lang.org/api/Math.html#hypot%28value1%2Cvalue2%29-instance-method
5 changes: 5 additions & 0 deletions analyzer-comments/crystal/darts/uses_hypot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Uses the hypot method

Congratulations, your solution uses the hypot method!

Your solution uses an efficient way of calculating the distance from the center of a dartboard and that's worth taking a moment to celebrate.
2 changes: 1 addition & 1 deletion analyzer-comments/crystal/sieve/do_not_use_div_rem.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Like the instructions mention, the purpose of this exercise is to build a Sieve of Eratosthenes without the use of operations such as division or modulo division.
Please refer to the [Wikipedia link][wikipedia] for a description of the algorithm.

Building the Sieve of Eratosthenes in an immutable language such as Crystal may feel a bit unnatural,
Building the Sieve of Eratosthenes without operations such as division or modulo division can be tricky.
but it is a beautiful algorithm invented more than two millennia ago that is worth learning and implementing.

[wikipedia]: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
4 changes: 4 additions & 0 deletions analyzer-comments/crystal/weighing-machine/missing_method.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Missing %{method_name} method call

Like the instructions mention, the purpose of this exercise is to learn about getters and setters.
Manually defining these methods is not inherently bad, but can lead to code which is more verbose and harder to maintain.
Loading