rubycritic 0.0.16 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -2
  3. data/CONTRIBUTING.md +62 -13
  4. data/README.md +31 -15
  5. data/lib/rubycritic/analysers/adapters/ast_node.rb +35 -0
  6. data/lib/rubycritic/analysers/{config.reek → adapters/config.reek} +0 -0
  7. data/lib/rubycritic/analysers/adapters/flay.rb +13 -0
  8. data/lib/rubycritic/analysers/adapters/flog.rb +17 -0
  9. data/lib/rubycritic/analysers/adapters/reek.rb +13 -0
  10. data/lib/rubycritic/analysers/churn.rb +1 -1
  11. data/lib/rubycritic/{adapters/complexity/flog.rb → analysers/complexity.rb} +5 -5
  12. data/lib/rubycritic/{adapters/smell → analysers/smells}/flay.rb +5 -5
  13. data/lib/rubycritic/{adapters/smell → analysers/smells}/flog.rb +5 -5
  14. data/lib/rubycritic/{adapters/smell → analysers/smells}/reek.rb +5 -5
  15. data/lib/rubycritic/analysers/stats.rb +5 -4
  16. data/lib/rubycritic/analysers_runner.rb +14 -10
  17. data/lib/rubycritic/report_generators/assets/stylesheets/application.css +15 -3
  18. data/lib/rubycritic/report_generators/base.rb +1 -0
  19. data/lib/rubycritic/report_generators/templates/code_file.html.erb +6 -6
  20. data/lib/rubycritic/report_generators/templates/code_index.html.erb +1 -1
  21. data/lib/rubycritic/report_generators/templates/smells_index.html.erb +5 -3
  22. data/lib/rubycritic/report_generators/view_helpers.rb +1 -3
  23. data/lib/rubycritic/version.rb +1 -1
  24. data/rubycritic.gemspec +3 -3
  25. data/test/analysers_test_helper.rb +3 -0
  26. data/test/lib/rubycritic/analysers/churn_test.rb +10 -14
  27. data/test/lib/rubycritic/analysers/complexity_test.rb +12 -0
  28. data/test/lib/rubycritic/{adapters/smell → analysers/smells}/flay_test.rb +3 -3
  29. data/test/lib/rubycritic/{adapters/smell → analysers/smells}/flog_test.rb +4 -6
  30. data/test/lib/rubycritic/{adapters/smell → analysers/smells}/reek_test.rb +5 -7
  31. data/test/lib/rubycritic/analysers/stats_test.rb +20 -0
  32. data/test/lib/rubycritic/configuration_test.rb +14 -3
  33. data/test/lib/rubycritic/core/analysed_file_test.rb +16 -1
  34. data/test/lib/rubycritic/core/smell_test.rb +0 -1
  35. data/test/lib/rubycritic/report_generators/view_helpers_test.rb +96 -0
  36. data/test/samples/stats/empty_example.rb +0 -0
  37. data/test/samples/stats/example.rb +7 -0
  38. metadata +38 -27
  39. data/lib/rubycritic/analysers/flay.rb +0 -15
  40. data/lib/rubycritic/analysers/flog.rb +0 -19
  41. data/lib/rubycritic/analysers/reek.rb +0 -15
  42. data/test/lib/rubycritic/adapters/complexity/flog_test.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a43f9d486a902fa7eda73e1df3e492cdb6ab085
4
- data.tar.gz: a29c16803a4e83f4b559065630b024b76b45a69c
3
+ metadata.gz: fceb73a4e6b94b34fcfc88f846367c0db8abf85d
4
+ data.tar.gz: b1b3714fe7efd0fbcc178139763c894730689b0d
5
5
  SHA512:
6
- metadata.gz: d0720b07a319110c0cb31dc6c5ca1ec69fef4eb60d7759069ba1e1e869a16f537d1e7d49553aa5ca544ccc91993c481f16f6fe7da2abe8917358499f952e2436
7
- data.tar.gz: 05e48772690e0230b7e8d5788751204e754ccaaf0c4e40d72a4e5520fc0bad81ddc3f87a09f141d9a494372de94ae9c1e6df5adf808d2b765de22a3ae23294d1
6
+ metadata.gz: a51d03f7b9c0b888496bc18b1366bd15ae43ab92abca874d57aa2625541ba2434502a284e0bb2d649e703a13cb00023079865ba408f2e3f9412fa51a54f5cbd9
7
+ data.tar.gz: 77ac17f55cbf455d8bf4419a09bdc75bd8a5db4f69588230979574fcd7a14a35bce36c1c49044676ed9e3c64b6bc148b7b712dc7552187749b8bc178fbbb2ed0
data/.travis.yml CHANGED
@@ -3,8 +3,8 @@ language: ruby
3
3
  rvm:
4
4
  - 1.9.3
5
5
  - 2.0.0
6
- - 2.1.1
7
- - rbx-2
6
+ - 2.1
8
7
  - jruby
8
+ - rbx-2
9
9
 
10
10
  script: "bundle exec rake"
data/CONTRIBUTING.md CHANGED
@@ -1,19 +1,68 @@
1
1
  Contributing
2
2
  ============
3
3
 
4
+ RubyCritic is open source and contributions from the community are encouraged! No contribution is too small. Please consider:
5
+
6
+ * [Writing some Code](#writing-some-code)
7
+ * [Improving the Documentation](#improving-the-documentation)
8
+ * [Reporting a Bug](#reporting-a-bug)
9
+
10
+ Writing some Code
11
+ -----------------
12
+
13
+ If you want to squash a bug or add a new feature, follow these guidelines:
14
+
4
15
  1. Fork the project.
5
- 2. Create your feature branch (`git checkout -b my-new-feature`).
6
- 3. Stage partial-file changesets (`git -p`).
7
- 4. Commit your changes (`git commit`).
8
- Make exactly as many commits as you need.
9
- Too many is confusing. Too few will result in epic diffs. Strive for just the right number.
10
- Each commit should do one thing and one thing only.
11
- Follow [these guidelines][1] when writing your commit messages.
12
- 5. [Hide the sausage making][2]. Squash, split and reorder commits if necessary (`git rebase -i`).
13
- For a more in-depth look at interactive rebasing, be sure to check [how to rewrite history][3].
14
- 6. Push to the branch (`git push origin my-new-feature`).
15
- 7. Create new Pull Request.
16
+
17
+ 2. Create a feature branch (`git checkout -b my-new-feature`).
18
+
19
+ 3. Make your changes. Include tests for your changes, otherwise I may accidentally break them in the future.
20
+
21
+ 4. Run the tests with the `rake` command. Make sure that they are still passing.
22
+
23
+ 5. Stage partial-file changesets (`git -p`).
24
+
25
+ 6. Commit your changes (`git commit`).
26
+ Make exactly as many commits as you need.
27
+ Each commit should do one thing and one thing only. For example, all whitespace fixes should be relegated to a single commit.
28
+
29
+ 7. Write descriptive commit messages, in accordance with [these guidelines][1].
30
+
31
+ 8. [Hide the sausage making][3]. Squash, split and reorder commits if necessary (`git rebase -i`).
32
+ For a more in-depth look at interactive rebasing, be sure to check [how to rewrite history][4].
33
+
34
+ 9. Push to the branch to GitHub (`git push origin my-new-feature`).
35
+
36
+ 10. Create a new [Pull Request][5] and send it to be merged with the master branch.
37
+
38
+ Improving the Documentation
39
+ ---------------------------
40
+
41
+ You are encouraged to clarify how something works or to simply fix a typo. Please include `[ci skip]` on a new line in your commit message. This will signal [Travis][2] that running the test suite is not necessary for these changes.
42
+
43
+ Reporting a Bug
44
+ ---------------
45
+
46
+ If you are experiencing unexpected behavior and, after having read Rubycritic's documentation, are convinced this behavior is a bug, please:
47
+
48
+ 1. Search the [issues tracker][6] to see if it was already reported / fixed.
49
+
50
+ 2. Include the Ruby and RubyCritic versions in your report. Here's a little table to help you out:
51
+
52
+ ```
53
+ | | Version |
54
+ |------------|---------|
55
+ | Ruby | 2.1.2 |
56
+ | RubyCritic | 1.0.0 |
57
+ ```
58
+
59
+ The more information you provide, the easier it will be to track down the issue and fix it.
60
+
61
+ 3. Create a new issue.
16
62
 
17
63
  [1]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
18
- [2]: http://sethrobertson.github.io/GitBestPractices/#sausage
19
- [3]: http://git-scm.com/book/en/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages
64
+ [2]: https://travis-ci.org
65
+ [3]: http://sethrobertson.github.io/GitBestPractices/#sausage
66
+ [4]: http://git-scm.com/book/en/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages
67
+ [5]: https://help.github.com/articles/creating-a-pull-request
68
+ [6]: https://github.com/whitesmith/rubycritic/issues
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  RubyCritic
2
- ===========
2
+ ==========
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/rubycritic.svg)](http://badge.fury.io/rb/rubycritic)
5
5
  [![Build Status](https://travis-ci.org/whitesmith/rubycritic.svg?branch=master)](https://travis-ci.org/whitesmith/rubycritic)
6
6
  [![Code Climate](http://img.shields.io/codeclimate/github/whitesmith/rubycritic.svg)](https://codeclimate.com/github/whitesmith/rubycritic)
7
7
 
8
- RubyCritic is a gem that wraps around static analysis gems such as [Reek][1]
9
- and [Flay][2] to provide a quality report of your Ruby code.
8
+ <img src="http://i.imgur.com/66HACCD.png" alt="RubyCritic Icon" align="right" />
9
+ RubyCritic is a gem that wraps around static analysis gems such as [Reek][1], [Flay][2] and [Flog][3] to provide a quality report of your Ruby code.
10
10
 
11
11
  This gem provides features such as:
12
12
 
@@ -42,8 +42,8 @@ This gem provides features such as:
42
42
 
43
43
  ![RubyCritic file code screenshot](http://i.imgur.com/KLVrhMm.png)
44
44
 
45
- Installation
46
- ------------
45
+ Getting Started
46
+ ---------------
47
47
 
48
48
  RubyCritic can be installed with the following command:
49
49
 
@@ -80,23 +80,39 @@ Alternatively you can pass `rubycritic` a list of files and directories to check
80
80
  $ rubycritic app lib/foo.rb
81
81
  ```
82
82
 
83
- By default, RubyCritic generates its report in `tmp/rubycritic`. You can customize the output directory using the `path` option. You can use relative paths:
83
+ For a full list of the command-line options run:
84
84
 
85
85
  ```bash
86
- rubycritic --path tmp/custom_dir # outputs to tmp/custom_dir
86
+ $ rubycritic --help
87
87
  ```
88
88
 
89
- Or full paths:
89
+ | Command flag | Description |
90
+ |--------------------------|-----------------------------------------|
91
+ | `-v/--version` | Displays the current version and exits. |
92
+ | `-p/--path` | Customizes the output directory. |
90
93
 
91
- ```bash
92
- rubycritic --path $HOME/tmp/custom_dir # outputs to $HOME/tmp/custom_dir
93
- ```
94
+ Alternative Usage Methods
95
+ -------------------------
94
96
 
95
- For a full list of the command-line options run:
97
+ If you're fond of Guard you might like [guard-rubycritic][4]. It automatically analyses your Ruby files as they are modified.
96
98
 
97
- ```bash
98
- $ rubycritic --help
99
- ```
99
+ For continuous integration, you can give [Jenkins CI][5] a spin. With it, you can easily build your own (poor-man's) Code Climate!
100
+
101
+ Improving RubyCritic
102
+ --------------------
103
+
104
+ RubyCritic doesn't have to remain a second choice to other code quality analysis services. Together, we can improve it and continue to build on the great code metric tools that are available in the Ruby ecosystem.
105
+
106
+ Arguably, the [better_errors gem][6] only got popular after receiving a [(pretty awesome) Pull Request][7] that changed its page design.
107
+
108
+ Similarly, Pull Requests that improve the look and feel of the gem, that tweak the calculation of ratings or that fix existing issues will be most welcome. This is my first gem, so just commenting on an issue and giving some insight into how something should work will be appreciated. No contribution is too small.
109
+
110
+ See RubyCritic's [contribution guidelines](CONTRIBUTING.md) about how to proceed.
100
111
 
101
112
  [1]: https://github.com/troessner/reek
102
113
  [2]: https://github.com/seattlerb/flay
114
+ [3]: https://github.com/seattlerb/flog
115
+ [4]: https://github.com/whitesmith/guard-rubycritic
116
+ [5]: http://jenkins-ci.org/
117
+ [6]: https://github.com/charliesome/better_errors
118
+ [7]: https://github.com/charliesome/better_errors/pull/22
@@ -0,0 +1,35 @@
1
+ module Parser
2
+ module AST
3
+
4
+ class Node
5
+ def count_nodes_of_type(*types)
6
+ count = 0
7
+ recursive_children do |child|
8
+ count += 1 if types.include?(child.type)
9
+ end
10
+ count
11
+ end
12
+
13
+ def recursive_children
14
+ children.each do |child|
15
+ next unless child.is_a?(Parser::AST::Node)
16
+ yield child
17
+ child.recursive_children { |grand_child| yield grand_child }
18
+ end
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+
25
+ module Rubycritic
26
+ module AST
27
+
28
+ class EmptyNode
29
+ def count_nodes_of_type(*types)
30
+ 0
31
+ end
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,13 @@
1
+ require "flay"
2
+
3
+ module Rubycritic
4
+
5
+ class Flay < ::Flay
6
+ def initialize(paths)
7
+ super()
8
+ process(*paths)
9
+ analyze
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,17 @@
1
+ require "flog"
2
+
3
+ module Rubycritic
4
+
5
+ class Flog < ::Flog
6
+ DEFAULT_OPTIONS = {
7
+ :all => true,
8
+ :continue => true,
9
+ :methods => true
10
+ }
11
+
12
+ def initialize
13
+ super(DEFAULT_OPTIONS)
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,13 @@
1
+ require "reek"
2
+
3
+ module Rubycritic
4
+
5
+ class Reek < ::Reek::Examiner
6
+ DEFAULT_CONFIG_FILES = [File.expand_path("../config.reek", __FILE__)]
7
+
8
+ def initialize(paths)
9
+ super(Array(paths), DEFAULT_CONFIG_FILES)
10
+ end
11
+ end
12
+
13
+ end
@@ -7,7 +7,7 @@ module Rubycritic
7
7
  @source_control_system = source_control_system
8
8
  end
9
9
 
10
- def churn
10
+ def run
11
11
  @analysed_files.each do |analysed_file|
12
12
  analysed_file.churn = @source_control_system.revisions_count(analysed_file.path)
13
13
  analysed_file.committed_at = @source_control_system.date_of_last_commit(analysed_file.path)
@@ -1,15 +1,15 @@
1
- require "rubycritic/analysers/flog"
1
+ require "rubycritic/analysers/adapters/flog"
2
2
 
3
3
  module Rubycritic
4
- module ComplexityAdapter
4
+ module Analyser
5
5
 
6
- class Flog
6
+ class Complexity
7
7
  def initialize(analysed_files)
8
- @flog = Analyser::Flog.new
8
+ @flog = Flog.new
9
9
  @analysed_files = analysed_files
10
10
  end
11
11
 
12
- def complexity
12
+ def run
13
13
  @analysed_files.each do |analysed_file|
14
14
  @flog.reset
15
15
  @flog.flog(analysed_file.path)
@@ -1,16 +1,16 @@
1
- require "rubycritic/analysers/flay"
1
+ require "rubycritic/analysers/adapters/flay"
2
2
  require "rubycritic/core/smell"
3
3
 
4
4
  module Rubycritic
5
- module SmellAdapter
5
+ module Analyser
6
6
 
7
- class Flay
7
+ class FlaySmells
8
8
  def initialize(analysed_files)
9
9
  @analysed_files = paths_to_analysed_files(analysed_files)
10
- @flay = Analyser::Flay.new(@analysed_files.keys)
10
+ @flay = Flay.new(@analysed_files.keys)
11
11
  end
12
12
 
13
- def smells
13
+ def run
14
14
  @flay.hashes.each do |structural_hash, nodes|
15
15
  smell = create_smell(structural_hash, nodes)
16
16
  nodes.map(&:file).uniq.each do |file|
@@ -1,19 +1,19 @@
1
- require "rubycritic/analysers/flog"
1
+ require "rubycritic/analysers/adapters/flog"
2
2
  require "rubycritic/core/smell"
3
3
 
4
4
  module Rubycritic
5
- module SmellAdapter
5
+ module Analyser
6
6
 
7
- class Flog
7
+ class FlogSmells
8
8
  HIGH_COMPLEXITY_SCORE_THRESHOLD = 25
9
9
  VERY_HIGH_COMPLEXITY_SCORE_THRESHOLD = 60
10
10
 
11
11
  def initialize(analysed_files)
12
- @flog = Analyser::Flog.new
12
+ @flog = Flog.new
13
13
  @analysed_files = analysed_files
14
14
  end
15
15
 
16
- def smells
16
+ def run
17
17
  @analysed_files.each do |analysed_file|
18
18
  add_smells_to(analysed_file)
19
19
  end
@@ -1,15 +1,15 @@
1
- require "rubycritic/analysers/reek"
1
+ require "rubycritic/analysers/adapters/reek"
2
2
  require "rubycritic/core/smell"
3
3
 
4
4
  module Rubycritic
5
- module SmellAdapter
5
+ module Analyser
6
6
 
7
- class Reek
7
+ class ReekSmells
8
8
  def initialize(analysed_files)
9
9
  @analysed_files = analysed_files
10
10
  end
11
11
 
12
- def smells
12
+ def run
13
13
  @analysed_files.each do |analysed_file|
14
14
  add_smells_to(analysed_file)
15
15
  end
@@ -18,7 +18,7 @@ module Rubycritic
18
18
  private
19
19
 
20
20
  def add_smells_to(analysed_file)
21
- Analyser::Reek.new(analysed_file.path).smells.each do |smell|
21
+ Reek.new(analysed_file.path).smells.each do |smell|
22
22
  analysed_file.smells << create_smell(smell)
23
23
  end
24
24
  end
@@ -1,4 +1,5 @@
1
- require "code_analyzer"
1
+ require "parser/current"
2
+ require "rubycritic/analysers/adapters/ast_node"
2
3
 
3
4
  module Rubycritic
4
5
  module Analyser
@@ -8,7 +9,7 @@ module Rubycritic
8
9
  @analysed_files = analysed_files
9
10
  end
10
11
 
11
- def stats
12
+ def run
12
13
  @analysed_files.each do |analysed_file|
13
14
  analysed_file.methods_count = methods_count(analysed_file.path)
14
15
  end
@@ -19,11 +20,11 @@ module Rubycritic
19
20
  def methods_count(path)
20
21
  content = File.read(path)
21
22
  node = parse_content(content)
22
- node.grep_nodes_count(sexp_type: [:def, :defs])
23
+ node.count_nodes_of_type(:def, :defs)
23
24
  end
24
25
 
25
26
  def parse_content(content)
26
- Sexp.from_array(Ripper::SexpBuilder.new(content).parse)[1]
27
+ Parser::CurrentRuby.parse(content) || AST::EmptyNode.new
27
28
  end
28
29
  end
29
30
 
@@ -1,14 +1,20 @@
1
- require "rubycritic/adapters/smell/flay"
2
- require "rubycritic/adapters/smell/flog"
3
- require "rubycritic/adapters/smell/reek"
4
- require "rubycritic/adapters/complexity/flog"
1
+ require "rubycritic/analysers/smells/flay"
2
+ require "rubycritic/analysers/smells/flog"
3
+ require "rubycritic/analysers/smells/reek"
4
+ require "rubycritic/analysers/complexity"
5
5
  require "rubycritic/analysers/churn"
6
6
  require "rubycritic/analysers/stats"
7
7
 
8
8
  module Rubycritic
9
9
 
10
10
  class AnalysersRunner
11
- SMELL_ANALYSERS = [SmellAdapter::Flay, SmellAdapter::Flog, SmellAdapter::Reek]
11
+ ANALYSERS = [
12
+ Analyser::FlaySmells,
13
+ Analyser::FlogSmells,
14
+ Analyser::ReekSmells,
15
+ Analyser::Complexity,
16
+ Analyser::Stats
17
+ ]
12
18
 
13
19
  def initialize(analysed_files, source_control_system)
14
20
  @analysed_files = analysed_files
@@ -16,12 +22,10 @@ module Rubycritic
16
22
  end
17
23
 
18
24
  def run
19
- SMELL_ANALYSERS.map do |analyser|
20
- analyser.new(@analysed_files).smells
25
+ ANALYSERS.map do |analyser|
26
+ analyser.new(@analysed_files).run
21
27
  end
22
- ComplexityAdapter::Flog.new(@analysed_files).complexity
23
- Analyser::Churn.new(@analysed_files, @source_control_system).churn
24
- Analyser::Stats.new(@analysed_files).stats
28
+ Analyser::Churn.new(@analysed_files, @source_control_system).run
25
29
  end
26
30
  end
27
31
 
@@ -59,7 +59,7 @@ html {
59
59
  height: 28px;
60
60
  }
61
61
 
62
- .index-table .circled-rating {
62
+ .index-table .circled-text {
63
63
  display: inline-block;
64
64
  line-height: 28px;
65
65
  }
@@ -112,7 +112,7 @@ html {
112
112
  border-radius: 50%;
113
113
  }
114
114
 
115
- .circled-rating {
115
+ .circled-text {
116
116
  text-align: center;
117
117
  color: white;
118
118
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
@@ -124,6 +124,18 @@ html {
124
124
  cursor: default;
125
125
  }
126
126
 
127
+ .smells-index-table .circled-text {
128
+ font-size: 10px;
129
+ }
130
+
131
+ .status-old {
132
+ background-color: #FFDC00;
133
+ }
134
+
135
+ .status-new {
136
+ background-color: #FF4136;
137
+ }
138
+
127
139
  .file-header {
128
140
  position: relative;
129
141
  padding: 0 0 10px 60px;
@@ -135,7 +147,7 @@ html {
135
147
  height: 50px;
136
148
  }
137
149
 
138
- .file-header .circled-rating {
150
+ .file-header .circled-text {
139
151
  float: left;
140
152
  line-height: 50px;
141
153
  font-size: 32px;
@@ -1,4 +1,5 @@
1
1
  require "erb"
2
+ require "pathname"
2
3
  require "rubycritic/report_generators/view_helpers"
3
4
 
4
5
  module Rubycritic
@@ -1,13 +1,13 @@
1
1
  <div class="file-header group">
2
- <span class="rating-<%= @analysed_file.rating.to_s.downcase %> circled-rating circle "><%= @analysed_file.rating %></span>
2
+ <span class="rating-<%= @analysed_file.rating.to_s.downcase %> circled-text circle "><%= @analysed_file.rating %></span>
3
3
  <h2 class="file-name"><%= @analysed_file.name %></h2>
4
4
 
5
5
  <span class="file-committed-at">
6
- <% if @analysed_file.committed_at %>
7
- Updated <%= timeago_tag(@analysed_file.committed_at) %></span>
8
- <% else %>
9
- Never committed
10
- <% end %>
6
+ <% if @analysed_file.committed_at %>
7
+ Updated <%= timeago_tag(@analysed_file.committed_at) %>
8
+ <% else %>
9
+ Never committed
10
+ <% end %>
11
11
  </span>
12
12
 
13
13
  <div class="file-stats group">
@@ -19,7 +19,7 @@
19
19
  <td class="numeric-cell"><%= analysed_file.complexity %></td>
20
20
  <td class="numeric-cell"><%= analysed_file.duplication %></td>
21
21
  <td class="numeric-cell"><%= analysed_file.smells.length %></td>
22
- <td class="centered-cell last-cell"><span class="rating-<%= analysed_file.rating.to_s.downcase %> circled-rating circle"><%= analysed_file.rating %></td>
22
+ <td class="centered-cell last-cell"><span class="rating-<%= analysed_file.rating.to_s.downcase %> circled-text circle"><%= analysed_file.rating %></span></td>
23
23
  </tr>
24
24
  <% end %>
25
25
  </tbody>
@@ -1,19 +1,21 @@
1
- <table id="js-index-table" class="index-table sortable-table">
1
+ <table id="js-index-table" class="smells-index-table index-table sortable-table">
2
2
  <thead>
3
3
  <tr>
4
4
  <th class="first-cell">Smell</th>
5
- <th class="last-cell">Locations</th>
5
+ <th>Locations</th>
6
+ <th class="centered-cell last-cell" title="Code smells introduced recently are marked as new. There's still time before they are committed!">Status</th>
6
7
  </tr>
7
8
  </thead>
8
9
  <tbody>
9
10
  <% @smells.each do |smell| %>
10
11
  <tr>
11
12
  <td class="first-cell"><%= smell.type %></td>
12
- <td class="last-cell">
13
+ <td>
13
14
  <% smell.locations.each do |location| %>
14
15
  <a href="<%= smell_location_path(location) %>"><%= location.file_name %></a>
15
16
  <% end %>
16
17
  </td>
18
+ <td class="centered-cell last-cell"><span class="status-<%= smell.status %> circled-text circle"><%= smell.status %></span></td>
17
19
  </tr>
18
20
  <% end %>
19
21
  </tbody>
@@ -1,5 +1,3 @@
1
- require "pathname"
2
-
3
1
  module Rubycritic
4
2
 
5
3
  module ViewHelpers
@@ -24,7 +22,7 @@ module Rubycritic
24
22
  end
25
23
 
26
24
  def smell_location_path(location)
27
- relative_path(root_directory + "#{location.pathname.sub_ext('.html')}#L#{location.line}")
25
+ file_path("#{location.pathname.sub_ext('.html')}#L#{location.line}")
28
26
  end
29
27
 
30
28
  private
@@ -1,3 +1,3 @@
1
1
  module Rubycritic
2
- VERSION = "0.0.16"
2
+ VERSION = "1.0.0"
3
3
  end
data/rubycritic.gemspec CHANGED
@@ -23,9 +23,9 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_runtime_dependency "virtus", "~> 1.0"
25
25
  spec.add_runtime_dependency "flay", "2.4.0"
26
- spec.add_runtime_dependency "flog", "4.2.0"
27
- spec.add_runtime_dependency "reek", "1.3.6"
28
- spec.add_runtime_dependency "code_analyzer", "0.4.5"
26
+ spec.add_runtime_dependency "flog", "4.2.1"
27
+ spec.add_runtime_dependency "reek", "1.3.8"
28
+ spec.add_runtime_dependency "parser", "~> 2.1"
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 1.3"
31
31
  spec.add_development_dependency "rake"
@@ -0,0 +1,3 @@
1
+ require "test_helper"
2
+
3
+ class AnalysedFileDouble < OpenStruct; end
@@ -1,4 +1,4 @@
1
- require "test_helper"
1
+ require "analysers_test_helper"
2
2
  require "rubycritic/analysers/churn"
3
3
  require "rubycritic/source_control_systems/base"
4
4
 
@@ -8,25 +8,21 @@ describe Rubycritic::Analyser::Churn do
8
8
  @source_control_system = SourceControlSystemDouble.new
9
9
  end
10
10
 
11
- describe "#churn" do
12
- it "calculates the churn of each file and adds it to analysed_files" do
13
- Rubycritic::Analyser::Churn.new(@analysed_files, @source_control_system).churn
14
- @analysed_files.each do |analysed_file|
15
- analysed_file.churn.must_equal 1
16
- end
11
+ it "calculates the churn of each file and adds it to analysed_files" do
12
+ Rubycritic::Analyser::Churn.new(@analysed_files, @source_control_system).run
13
+ @analysed_files.each do |analysed_file|
14
+ analysed_file.churn.must_equal 1
17
15
  end
16
+ end
18
17
 
19
- it "calculates the date of the last commit of each file and adds it to analysed_files" do
20
- Rubycritic::Analyser::Churn.new(@analysed_files, @source_control_system).churn
21
- @analysed_files.each do |analysed_file|
22
- analysed_file.committed_at.must_equal "2013-10-09 12:52:49 +0100"
23
- end
18
+ it "calculates the date of the last commit of each file and adds it to analysed_files" do
19
+ Rubycritic::Analyser::Churn.new(@analysed_files, @source_control_system).run
20
+ @analysed_files.each do |analysed_file|
21
+ analysed_file.committed_at.must_equal "2013-10-09 12:52:49 +0100"
24
22
  end
25
23
  end
26
24
  end
27
25
 
28
- class AnalysedFileDouble < OpenStruct; end
29
-
30
26
  class SourceControlSystemDouble < Rubycritic::SourceControlSystem::Base
31
27
  def revisions_count(path)
32
28
  1 # churn
@@ -0,0 +1,12 @@
1
+ require "analysers_test_helper"
2
+ require "rubycritic/analysers/complexity"
3
+
4
+ describe Rubycritic::Analyser::Complexity do
5
+ it "calculates the complexity of each file and adds it to analysed_files" do
6
+ analysed_files = [AnalysedFileDouble.new(:path => "test/samples/flog/complex.rb")]
7
+ Rubycritic::Analyser::Complexity.new(analysed_files).run
8
+ analysed_files.each do |analysed_file|
9
+ analysed_file.complexity.must_be_kind_of Numeric
10
+ end
11
+ end
12
+ end
@@ -1,9 +1,9 @@
1
1
  require "test_helper"
2
- require "rubycritic/adapters/smell/flay"
2
+ require "rubycritic/analysers/smells/flay"
3
3
  require "rubycritic/core/analysed_file"
4
4
  require "pathname"
5
5
 
6
- describe Rubycritic::SmellAdapter::Flay do
6
+ describe Rubycritic::Analyser::FlaySmells do
7
7
  before do
8
8
  @analysed_file = Rubycritic::AnalysedFile.new(
9
9
  :pathname => Pathname.new("test/samples/flay/smelly.rb"),
@@ -11,7 +11,7 @@ describe Rubycritic::SmellAdapter::Flay do
11
11
  :duplication => 0
12
12
  )
13
13
  analysed_files = [@analysed_file]
14
- Rubycritic::SmellAdapter::Flay.new(analysed_files).smells
14
+ Rubycritic::Analyser::FlaySmells.new(analysed_files).run
15
15
  end
16
16
 
17
17
  it "detects smells and adds them to analysed_files" do
@@ -1,11 +1,11 @@
1
- require "test_helper"
2
- require "rubycritic/adapters/smell/flog"
1
+ require "analysers_test_helper"
2
+ require "rubycritic/analysers/smells/flog"
3
3
 
4
- describe Rubycritic::SmellAdapter::Flog do
4
+ describe Rubycritic::Analyser::FlogSmells do
5
5
  before do
6
6
  @analysed_file = AnalysedFileDouble.new(:path => "test/samples/flog/smelly.rb", :smells => [])
7
7
  analysed_files = [@analysed_file]
8
- Rubycritic::SmellAdapter::Flog.new(analysed_files).smells
8
+ Rubycritic::Analyser::FlogSmells.new(analysed_files).run
9
9
  end
10
10
 
11
11
  it "detects smells and adds them to analysed_files" do
@@ -22,5 +22,3 @@ describe Rubycritic::SmellAdapter::Flog do
22
22
  smell.score.must_be_kind_of Numeric
23
23
  end
24
24
  end
25
-
26
- class AnalysedFileDouble < OpenStruct; end
@@ -1,12 +1,12 @@
1
- require "test_helper"
2
- require "rubycritic/adapters/smell/reek"
1
+ require "analysers_test_helper"
2
+ require "rubycritic/analysers/smells/reek"
3
3
 
4
- describe Rubycritic::SmellAdapter::Reek do
4
+ describe Rubycritic::Analyser::ReekSmells do
5
5
  context "when analysing a smelly file" do
6
6
  before do
7
7
  @analysed_file = AnalysedFileDouble.new(:path => "test/samples/reek/smelly.rb", :smells => [])
8
8
  analysed_files = [@analysed_file]
9
- Rubycritic::SmellAdapter::Reek.new(analysed_files).smells
9
+ Rubycritic::Analyser::ReekSmells.new(analysed_files).run
10
10
  end
11
11
 
12
12
  it "detects smells and adds them to analysed_files" do
@@ -23,7 +23,7 @@ describe Rubycritic::SmellAdapter::Reek do
23
23
  before do
24
24
  @analysed_file = AnalysedFileDouble.new(:path => "test/samples/reek/not_smelly.rb", :smells => [])
25
25
  analysed_files = [@analysed_file]
26
- Rubycritic::SmellAdapter::Reek.new(analysed_files)
26
+ Rubycritic::Analyser::ReekSmells.new(analysed_files).run
27
27
  end
28
28
 
29
29
  it "does not detect smells and does not add them to analysed files" do
@@ -31,5 +31,3 @@ describe Rubycritic::SmellAdapter::Reek do
31
31
  end
32
32
  end
33
33
  end
34
-
35
- class AnalysedFileDouble < OpenStruct; end
@@ -0,0 +1,20 @@
1
+ require "analysers_test_helper"
2
+ require "rubycritic/analysers/stats"
3
+
4
+ describe Rubycritic::Analyser::Stats do
5
+ context "when a file contains Ruby code" do
6
+ it "calculates the number of methods of each file and adds it to analysed_files" do
7
+ analysed_file = AnalysedFileDouble.new(:path => "test/samples/stats/example.rb")
8
+ Rubycritic::Analyser::Stats.new([analysed_file]).run
9
+ analysed_file.methods_count.must_equal 2
10
+ end
11
+ end
12
+
13
+ context "when a file is empty" do
14
+ it "calculates the number of methods as 0, adding it to analysed_files" do
15
+ analysed_file = AnalysedFileDouble.new(:path => "test/samples/stats/empty_example.rb")
16
+ Rubycritic::Analyser::Stats.new([analysed_file]).run
17
+ analysed_file.methods_count.must_equal 0
18
+ end
19
+ end
20
+ end
@@ -3,15 +3,26 @@ require "rubycritic/configuration"
3
3
 
4
4
  describe Rubycritic::Configuration do
5
5
  describe "#root" do
6
+ before do
7
+ @default = Rubycritic.configuration.root
8
+ end
9
+
6
10
  it "has a default" do
7
11
  Rubycritic.configuration.root.wont_be_empty
8
12
  end
9
13
 
10
- it "can be configured" do
11
- default = Rubycritic.configuration.root
14
+ it "can be set to a relative path" do
12
15
  Rubycritic.configuration.root = "foo"
13
16
  Rubycritic.configuration.root.must_equal File.expand_path("foo")
14
- Rubycritic.configuration.root = default
17
+ end
18
+
19
+ it "can be set to an absolute path" do
20
+ Rubycritic.configuration.root = "/foo"
21
+ Rubycritic.configuration.root.must_equal "/foo"
22
+ end
23
+
24
+ after do
25
+ Rubycritic.configuration.root = @default
15
26
  end
16
27
  end
17
28
  end
@@ -1,7 +1,6 @@
1
1
  require "test_helper"
2
2
  require "rubycritic/core/analysed_file"
3
3
  require "rubycritic/core/smell"
4
- require "rubycritic/core/location"
5
4
 
6
5
  describe Rubycritic::AnalysedFile do
7
6
  describe "attribute readers" do
@@ -51,6 +50,22 @@ describe Rubycritic::AnalysedFile do
51
50
  end
52
51
  end
53
52
 
53
+ describe "#complexity_per_method" do
54
+ context "when the file has no methods" do
55
+ it "returns a placeholder" do
56
+ analysed_file = Rubycritic::AnalysedFile.new(:complexity => 0, :methods_count => 0)
57
+ analysed_file.complexity_per_method.must_equal "N/A"
58
+ end
59
+ end
60
+
61
+ context "when the file has at least one method" do
62
+ it "returns the average complexity per method" do
63
+ analysed_file = Rubycritic::AnalysedFile.new(:complexity => 10, :methods_count => 2)
64
+ analysed_file.complexity_per_method.must_equal 5
65
+ end
66
+ end
67
+ end
68
+
54
69
  describe "#has_smells?" do
55
70
  it "returns true if the analysed_file has at least one smell" do
56
71
  analysed_file = Rubycritic::AnalysedFile.new(:smells => [SmellDouble.new])
@@ -1,6 +1,5 @@
1
1
  require "test_helper"
2
2
  require "rubycritic/core/smell"
3
- require "rubycritic/core/location"
4
3
 
5
4
  describe Rubycritic::Smell do
6
5
  describe "attribute readers" do
@@ -0,0 +1,96 @@
1
+ require "test_helper"
2
+ require "rubycritic/report_generators/view_helpers"
3
+ require "pathname"
4
+
5
+ describe Rubycritic::ViewHelpers do
6
+ context "when the file is in the root directory" do
7
+ let(:generator) { GeneratorDouble.new("foo.html") }
8
+
9
+ describe "#file_path" do
10
+ context "when the other file is in the same directory" do
11
+ it "creates a relative path to a file" do
12
+ generator.file_path("bar.html").to_s.must_equal "bar.html"
13
+ end
14
+ end
15
+
16
+ context "when the other file is in a subdirectory" do
17
+ it "creates a relative path to a file" do
18
+ generator.file_path("subdirectory/bar.html").to_s.must_equal "subdirectory/bar.html"
19
+ end
20
+ end
21
+ end
22
+
23
+ describe "#asset_path" do
24
+ it "creates a relative path to an asset" do
25
+ generator.asset_path("stylesheets", "application.css").to_s
26
+ .must_equal "assets/stylesheets/application.css"
27
+ end
28
+ end
29
+ end
30
+
31
+ context "when the file is in a subdirectory" do
32
+ let(:generator) { GeneratorDouble.new("subdirectory/foo.html") }
33
+
34
+ describe "#file_path" do
35
+ context "when the other file is in the same directory" do
36
+ it "creates a relative path to a file" do
37
+ generator.file_path("subdirectory/bar.html").to_s.must_equal "bar.html"
38
+ end
39
+ end
40
+
41
+ context "when the other file is in the root directory" do
42
+ it "creates a relative path to a file" do
43
+ generator.file_path("bar.html").to_s.must_equal "../bar.html"
44
+ end
45
+ end
46
+ end
47
+
48
+ describe "#asset_path" do
49
+ it "creates a relative path to an asset" do
50
+ generator.asset_path("stylesheets", "application.css").to_s
51
+ .must_equal "../assets/stylesheets/application.css"
52
+ end
53
+ end
54
+ end
55
+
56
+ context "when the file is n directories deep" do
57
+ let(:generator) { GeneratorDouble.new("lets/go/crazy/foo.html") }
58
+
59
+ describe "#file_path" do
60
+ context "when the other file is in the same directory" do
61
+ it "creates a relative path to a file" do
62
+ generator.file_path("lets/go/crazy/bar.html").to_s.must_equal "bar.html"
63
+ end
64
+ end
65
+
66
+ context "when the other file is in the root directory" do
67
+ it "creates a relative path to a file" do
68
+ generator.file_path("bar.html").to_s.must_equal "../../../bar.html"
69
+ end
70
+ end
71
+ end
72
+
73
+ describe "#asset_path" do
74
+ it "creates a relative path to an asset" do
75
+ generator.asset_path("stylesheets", "application.css").to_s
76
+ .must_equal "../../../assets/stylesheets/application.css"
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ class GeneratorDouble
83
+ include Rubycritic::ViewHelpers
84
+
85
+ def initialize(file)
86
+ @file = Pathname.new(file)
87
+ end
88
+
89
+ def file_directory
90
+ root_directory + @file.dirname
91
+ end
92
+
93
+ def root_directory
94
+ Pathname.new("root_directory")
95
+ end
96
+ end
File without changes
@@ -0,0 +1,7 @@
1
+ class Example
2
+ def self.one_class_method
3
+ end
4
+
5
+ def one_instance_method
6
+ end
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubycritic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilherme Simoes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-03 00:00:00.000000000 Z
11
+ date: 2014-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus
@@ -44,42 +44,42 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 4.2.0
47
+ version: 4.2.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 4.2.0
54
+ version: 4.2.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: reek
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 1.3.6
61
+ version: 1.3.8
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 1.3.6
68
+ version: 1.3.8
69
69
  - !ruby/object:Gem::Dependency
70
- name: code_analyzer
70
+ name: parser
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '='
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.4.5
75
+ version: '2.1'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '='
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.4.5
82
+ version: '2.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -154,15 +154,16 @@ files:
154
154
  - Rakefile
155
155
  - bin/rubycritic
156
156
  - lib/rubycritic.rb
157
- - lib/rubycritic/adapters/complexity/flog.rb
158
- - lib/rubycritic/adapters/smell/flay.rb
159
- - lib/rubycritic/adapters/smell/flog.rb
160
- - lib/rubycritic/adapters/smell/reek.rb
157
+ - lib/rubycritic/analysers/adapters/ast_node.rb
158
+ - lib/rubycritic/analysers/adapters/config.reek
159
+ - lib/rubycritic/analysers/adapters/flay.rb
160
+ - lib/rubycritic/analysers/adapters/flog.rb
161
+ - lib/rubycritic/analysers/adapters/reek.rb
161
162
  - lib/rubycritic/analysers/churn.rb
162
- - lib/rubycritic/analysers/config.reek
163
- - lib/rubycritic/analysers/flay.rb
164
- - lib/rubycritic/analysers/flog.rb
165
- - lib/rubycritic/analysers/reek.rb
163
+ - lib/rubycritic/analysers/complexity.rb
164
+ - lib/rubycritic/analysers/smells/flay.rb
165
+ - lib/rubycritic/analysers/smells/flog.rb
166
+ - lib/rubycritic/analysers/smells/reek.rb
166
167
  - lib/rubycritic/analysers/stats.rb
167
168
  - lib/rubycritic/analysers_runner.rb
168
169
  - lib/rubycritic/cli.rb
@@ -211,16 +212,19 @@ files:
211
212
  - lib/rubycritic/turbulence.rb
212
213
  - lib/rubycritic/version.rb
213
214
  - rubycritic.gemspec
214
- - test/lib/rubycritic/adapters/complexity/flog_test.rb
215
- - test/lib/rubycritic/adapters/smell/flay_test.rb
216
- - test/lib/rubycritic/adapters/smell/flog_test.rb
217
- - test/lib/rubycritic/adapters/smell/reek_test.rb
215
+ - test/analysers_test_helper.rb
218
216
  - test/lib/rubycritic/analysers/churn_test.rb
217
+ - test/lib/rubycritic/analysers/complexity_test.rb
218
+ - test/lib/rubycritic/analysers/smells/flay_test.rb
219
+ - test/lib/rubycritic/analysers/smells/flog_test.rb
220
+ - test/lib/rubycritic/analysers/smells/reek_test.rb
221
+ - test/lib/rubycritic/analysers/stats_test.rb
219
222
  - test/lib/rubycritic/configuration_test.rb
220
223
  - test/lib/rubycritic/core/analysed_file_test.rb
221
224
  - test/lib/rubycritic/core/location_test.rb
222
225
  - test/lib/rubycritic/core/smell_test.rb
223
226
  - test/lib/rubycritic/core/smells_array_test.rb
227
+ - test/lib/rubycritic/report_generators/view_helpers_test.rb
224
228
  - test/lib/rubycritic/smells_status_setter_test.rb
225
229
  - test/lib/rubycritic/source_control_systems/source_control_system_test.rb
226
230
  - test/lib/rubycritic/source_locator_test.rb
@@ -235,6 +239,8 @@ files:
235
239
  - test/samples/location/file_with_no_extension
236
240
  - test/samples/reek/not_smelly.rb
237
241
  - test/samples/reek/smelly.rb
242
+ - test/samples/stats/empty_example.rb
243
+ - test/samples/stats/example.rb
238
244
  - test/test_helper.rb
239
245
  homepage: https://github.com/whitesmith/rubycritic
240
246
  licenses:
@@ -261,16 +267,19 @@ signing_key:
261
267
  specification_version: 4
262
268
  summary: Ruby code smell detector
263
269
  test_files:
264
- - test/lib/rubycritic/adapters/complexity/flog_test.rb
265
- - test/lib/rubycritic/adapters/smell/flay_test.rb
266
- - test/lib/rubycritic/adapters/smell/flog_test.rb
267
- - test/lib/rubycritic/adapters/smell/reek_test.rb
270
+ - test/analysers_test_helper.rb
268
271
  - test/lib/rubycritic/analysers/churn_test.rb
272
+ - test/lib/rubycritic/analysers/complexity_test.rb
273
+ - test/lib/rubycritic/analysers/smells/flay_test.rb
274
+ - test/lib/rubycritic/analysers/smells/flog_test.rb
275
+ - test/lib/rubycritic/analysers/smells/reek_test.rb
276
+ - test/lib/rubycritic/analysers/stats_test.rb
269
277
  - test/lib/rubycritic/configuration_test.rb
270
278
  - test/lib/rubycritic/core/analysed_file_test.rb
271
279
  - test/lib/rubycritic/core/location_test.rb
272
280
  - test/lib/rubycritic/core/smell_test.rb
273
281
  - test/lib/rubycritic/core/smells_array_test.rb
282
+ - test/lib/rubycritic/report_generators/view_helpers_test.rb
274
283
  - test/lib/rubycritic/smells_status_setter_test.rb
275
284
  - test/lib/rubycritic/source_control_systems/source_control_system_test.rb
276
285
  - test/lib/rubycritic/source_locator_test.rb
@@ -285,4 +294,6 @@ test_files:
285
294
  - test/samples/location/file_with_no_extension
286
295
  - test/samples/reek/not_smelly.rb
287
296
  - test/samples/reek/smelly.rb
297
+ - test/samples/stats/empty_example.rb
298
+ - test/samples/stats/example.rb
288
299
  - test/test_helper.rb
@@ -1,15 +0,0 @@
1
- require "flay"
2
-
3
- module Rubycritic
4
- module Analyser
5
-
6
- class Flay < ::Flay
7
- def initialize(paths)
8
- super()
9
- process(*paths)
10
- analyze
11
- end
12
- end
13
-
14
- end
15
- end
@@ -1,19 +0,0 @@
1
- require "flog"
2
-
3
- module Rubycritic
4
- module Analyser
5
-
6
- class Flog < ::Flog
7
- DEFAULT_OPTIONS = {
8
- :all => true,
9
- :continue => true,
10
- :methods => true
11
- }
12
-
13
- def initialize
14
- super(DEFAULT_OPTIONS)
15
- end
16
- end
17
-
18
- end
19
- end
@@ -1,15 +0,0 @@
1
- require "reek"
2
-
3
- module Rubycritic
4
- module Analyser
5
-
6
- class Reek < ::Reek::Examiner
7
- DEFAULT_CONFIG_FILES = [File.expand_path("../config.reek", __FILE__)]
8
-
9
- def initialize(paths)
10
- super(Array(paths), DEFAULT_CONFIG_FILES)
11
- end
12
- end
13
-
14
- end
15
- end
@@ -1,18 +0,0 @@
1
- require "test_helper"
2
- require "rubycritic/analysers/flog"
3
- require "rubycritic/adapters/complexity/flog"
4
-
5
- describe Rubycritic::ComplexityAdapter::Flog do
6
- before do
7
- @analysed_files = [AnalysedFileDouble.new(:path => "test/samples/flog/complex.rb")]
8
- Rubycritic::ComplexityAdapter::Flog.new(@analysed_files).complexity
9
- end
10
-
11
- describe "#complexity" do
12
- it "calculates the complexity of each file and adds it to analysed_files" do
13
- @analysed_files.each do |analysed_file|
14
- analysed_file.complexity.must_be_kind_of Numeric
15
- end
16
- end
17
- end
18
- end