forked from troessner/reek
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25ac491
commit 28732f4
Showing
9 changed files
with
28 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,8 @@ | ||
$:.unshift File.dirname(__FILE__) | ||
|
||
require 'reek/code_parser' | ||
require 'reek/report' | ||
require 'reek/smells/smells' | ||
|
||
module Reek # :doc: | ||
|
||
VERSION = '0.3.1.1' | ||
|
||
# | ||
# Analyse the given source, looking for code smells. | ||
# The source can be a filename or a String containing Ruby code. | ||
# Returns a +Report+ listing the smells found. | ||
# | ||
class Analyser | ||
def initialize(src) | ||
@source = src | ||
@config = SmellConfig.new | ||
src.configure(@config) | ||
end | ||
|
||
# | ||
# Returns a +Report+ listing the smells found. | ||
# | ||
def analyse | ||
report = Report.new | ||
smells = @config.smell_listeners | ||
CodeParser.new(report, smells).check_source(@source.source) | ||
report | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
require 'reek/code_parser' | ||
|
||
module Reek | ||
class Source | ||
attr_reader :source | ||
|
||
def initialize(filename) | ||
if File.exists?(filename) | ||
@source = IO.readlines(filename).join | ||
@dir = File.dirname(filename) | ||
@filename = filename | ||
else | ||
@source = filename | ||
@dir = '.' | ||
@filename = "source code" | ||
end | ||
end | ||
|
||
def configure(config) | ||
config.load_local(@dir) | ||
# | ||
# Analyse the given source, looking for code smells. | ||
# The source can be a filename or a String containing Ruby code. | ||
# Returns a +Report+ listing the smells found. | ||
# | ||
def analyse | ||
report = Report.new | ||
smells = SmellConfig.new.load_local(@dir).smell_listeners | ||
CodeParser.new(report, smells).check_source(@source) | ||
report | ||
end | ||
|
||
def to_s | ||
@filename | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
require 'reek/smells/smells' | ||
require 'reek/code_context' | ||
|
||
module Reek | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters