Skip to content

Commit

Permalink
Merge pull request #1745 from JuanVqz/fix_editor_highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
troessner authored Oct 18, 2023
2 parents d3c2968 + 7adb7c2 commit 79350d9
Show file tree
Hide file tree
Showing 41 changed files with 190 additions and 189 deletions.
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ We do not use the popular "foo" / "bar" naming when it comes to the question
[military alphabet](https://en.wikipedia.org/wiki/NATO_phonetic_alphabet) in
ascending order which means that we would write this

```Ruby
```ruby
class Foo
def bar(baz)
baz.quux
Expand All @@ -81,7 +81,7 @@ end

rather like this:

```Ruby
```ruby
class Alfa
def bravo(charlie)
charlie.delta
Expand Down Expand Up @@ -199,11 +199,11 @@ In this example we assume the current version is 5.3.1 and you want to update to
* Update the version in `lib/reek/version.rb`
* List all relevant changes in `CHANGELOG.md`
* Update the version number in our cucumber features, otherwise the build will fail. You can do this quite easily via
```Bash
```bash
find features/ -type f -exec sed -i '' 's/v5.3.1/v5.3.2/g' {} +
```
* Push the branch, create a pull request, have it reviewed and merged
* Pull the latest master and then do a
```Bash
```bash
bundle exec rake release
```
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ or [that one](https://troessner.svbtle.com/the-latest-and-greatest-additions-to-

Install it via rubygems:

```Bash
```bash
gem install reek
```

and run it like this:

```Bash
```bash
reek [options] [dir_or_source_file]*
```

## Example

Imagine a source file `demo.rb` containing:

```Ruby
```ruby
# Smelly class
class Smelly
# This will reek of UncommunicativeMethodName
Expand Down Expand Up @@ -109,7 +109,7 @@ language and business logic.
That said, an example might help you get going. Have a look at this sample of a
Ruby on Rails model (be aware that this is truncated, not working code):

```Ruby
```ruby
class ShoppingCart < ActiveRecord::Base
has_many :items

Expand Down Expand Up @@ -138,7 +138,7 @@ would report:
Fixing this is pretty straightforward. Put the gross price calculation for a single item
where it belongs, which would be the `Item` class:

```Ruby
```ruby
class ShoppingCart < ActiveRecord::Base
has_many :items

Expand All @@ -163,33 +163,33 @@ those first when you have a warning that you don't know how to deal with.

There are multiple ways you can have Reek work on sources, the most common one just being

```Bash
```bash
reek lib/
```

If you don't pass any source arguments to Reek it just takes the current working directory as source.

So

```Bash
```bash
reek
```

is the exact same thing as being explicit:

```Bash
```bash
reek .
```

Additionally you can pipe code to Reek like this:

```Bash
```bash
echo "class C; def m; end; end" | reek
```

This would print out:

```Bash
```bash
$stdin -- 3 warnings:
[1]:C has no descriptive comment (IrresponsibleModule)
[1]:C has the name 'C' (UncommunicativeModuleName)
Expand Down Expand Up @@ -217,7 +217,7 @@ for up to date details of exactly what Reek will check in your code.
because it is [kind of controversial](https://github.com/troessner/reek/issues/844) which means
you have to explicitly activate it in your configuration via

```Yaml
```yaml
UnusedPrivateMethod:
enabled: true
```
Expand All @@ -226,7 +226,7 @@ UnusedPrivateMethod:
as well that can turn out to be really unforgiving.
As a consequence, we made it possible to disable it for non-public methods like this:
```Yaml
```yaml
---
UtilityFunction:
public_methods_only: true
Expand All @@ -238,7 +238,7 @@ UtilityFunction:
For a basic overview, run
```Ruby
```ruby
reek --help
```

Expand Down Expand Up @@ -326,7 +326,7 @@ directories:
exclude_paths:
- lib/legacy
- lib/rake/legacy_tasks
- lib/smelly.rb
- lib/smelly.rb
```
As you see above, Reek's configuration consists of 3 different sections denoted by 3 different keys:
Expand Down Expand Up @@ -393,7 +393,7 @@ In case you need to suppress a smell warning and you can't or don't want to
use configuration files for whatever reasons you can also use special
source code comments like this:

```Ruby
```ruby
# This method smells of :reek:NestedIterators
def smelly_method foo
foo.each {|bar| bar.each {|baz| baz.qux}}
Expand All @@ -402,7 +402,7 @@ end

You can even pass in smell specific configuration settings:

```Ruby
```ruby
# :reek:NestedIterators { max_allowed_nesting: 2 }
def smelly_method foo
foo.each {|bar| bar.each {|baz| baz.qux}}
Expand Down Expand Up @@ -430,7 +430,7 @@ codebase this might not be an option.
Fortunately Reek provides a 'todo' flag which you can use to generate a configuration that will
suppress all smell warnings for the current codebase:

```Bash
```bash
reek --todo lib/
```

Expand All @@ -445,7 +445,7 @@ If for whatever reasons you decide to put '.reek.yml' somewhere else where
Reek won't pick it up automatically you need to tell Reek explicitly to do so
via:

```Bash
```bash
reek -c whatever/.reek.yml lib/
```

Expand All @@ -459,7 +459,7 @@ and instead abort execution. It also will not take **any** other configuration f

This means that when you run

```Bash
```bash
reek -c other_configuration.reek --todo lib/
```

Expand All @@ -472,7 +472,7 @@ but keep in mind that this is not the intended use case of this feature.

Besides the obvious

```Bash
```bash
reek [options] [dir_or_source_file]*
```

Expand Down Expand Up @@ -521,7 +521,7 @@ bundle exec rake console
You can also use Pry while running the tests by adding the following at the
point where you want to start debugging:

```Ruby
```ruby
require 'pry'
binding.pry
```
Expand Down Expand Up @@ -567,7 +567,7 @@ Reek supports 5 output formats:
Making Reek "Rails"-friendly is fairly simple since we support directory specific configurations (`directory directives` in Reek talk).
Just add this to your configuration file:

```Yaml
```yaml
directories:
"app/controllers":
IrresponsibleModule:
Expand Down
6 changes: 3 additions & 3 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ XMLReport

Given you have the following configuration file called `.reek.yml` in your root directory:

```Yaml
```yaml
---
IrresponsibleModule:
enabled: false
Expand All @@ -102,7 +102,7 @@ configuration explicitly, you can use one of the methods below.
You can now use either
```Ruby
```ruby
Reek::Configuration::AppConfiguration.from_path Pathname.new('config.reek')
```

Expand All @@ -111,7 +111,7 @@ to `Reek::Configuration::AppConfiguration.from_hash`.

Given the example above you would load that as follows:

```Ruby
```ruby
require 'reek'

config_hash = { 'IrresponsibleModule' => { 'enabled' => false } }
Expand Down
2 changes: 1 addition & 1 deletion docs/Attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The same holds to a lesser extent for getters, but Reek doesn't flag those.

Given:

```Ruby
```ruby
class Klass
attr_accessor :dummy
end
Expand Down
2 changes: 1 addition & 1 deletion docs/Basic-Smell-Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This would not report FeatureEnvy for the instance method `MyModel#do_things`, t

Sometimes just strings are not enough for configuration. E.g. consider this code sample:

```Ruby
```ruby
class Klass
def foo1; end
def foo1bar; end
Expand Down
2 changes: 1 addition & 1 deletion docs/Boolean-Parameter.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ that is not really necessary, thus increasing coupling.

Given

```Ruby
```ruby
class Dummy
def hit_the_switch(switch = true)
if switch
Expand Down
4 changes: 2 additions & 2 deletions docs/Class-Variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ For a detailed explanation, check out [this article](http://4thmouse.com/index.p

Given

```Ruby
```ruby
class Dummy
@@class_variable = :whatever
end
Expand All @@ -29,7 +29,7 @@ test.rb -- 1 warning:

You can use class-instance variable to mitigate the problem (as also suggested in the linked article above):

```Ruby
```ruby
class Dummy
@class_variable = :whatever
end
Expand Down
24 changes: 12 additions & 12 deletions docs/Command-Line-Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Reek follows standard Unix convention for passing arguments.

Check out

```Bash
```bash
reek -h
```

Expand All @@ -18,40 +18,40 @@ In case your configuration file is not in the standard location (that would be y
whatever directory you're running Reek from) you can specify a configuration file with the `-c` option
like this:

```Bash
```bash
reek -c /somewhere/on/your/filesystem/reek_config.yml lib/
```

## Telling Reek Which Code to Check

Probably the most standard use case would be to check all Ruby files in the lib directory:

```Bash
```bash
reek lib/*.rb
```

In general, if any command-line argument is a directory, Reek searches that directory and all sub-directories for Ruby source files. Thus

```Bash
```bash
reek lib
```

would be equivalent to

```Bash
```bash
reek lib/**/*.rb
```

Occasionally you may want to quickly check a code snippet without going to the trouble of creating a file to hold it. You can pass the snippet directly to Reek's standard input:

```Bash
```bash
echo "def x() true end" | reek
```

To just check all Ruby files in the current directory, you can simply run it
with no parameters:

```Bash
```bash
reek
```

Expand All @@ -63,13 +63,13 @@ option and passing in the smell name.
For example, to only check for [Utility Function](Utility-Function.md), you
would use:

```Bash
```bash
reek --smell UtilityFunction
```

You can select several smells by repeating the `--smell` option like so:

```Bash
```bash
reek --smell UtilityFunction --smell UncommunicativeMethodName
```

Expand All @@ -79,7 +79,7 @@ reek --smell UtilityFunction --smell UncommunicativeMethodName

By passing in a "-n" flag to the _reek_ command, the output will suppress the line numbers:

```Bash
```bash
$ reek -n mess.rb
```

Expand All @@ -91,7 +91,7 @@ mess.rb -- 2 warnings:

Otherwise line numbers will be shown as default at the beginning of each warning in square brackets:

```Bash
```bash
$ reek mess.rb
```

Expand All @@ -108,7 +108,7 @@ This mode can be enabled via the "-U" or "--documentation" flag.

So for instance, if your test file would smell of _ClassVariable_, this is what the _reek_ output would look like:

```Bash
```bash
reek -U test.rb
```
```
Expand Down
Loading

0 comments on commit 79350d9

Please sign in to comment.