Class: DontRepeatYourself::SimianResults

Inherits:
Object
  • Object
show all
Defined in:
lib/dont_repeat_yourself/simian_results.rb

Defined Under Namespace

Classes: DuplicateLinesBlock, DuplicateLinesSet

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(simian_log_yaml) ⇒ SimianResults

Returns a new instance of SimianResults.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dont_repeat_yourself/simian_results.rb', line 11

def initialize(simian_log_yaml)
  @simian_log_yaml = simian_log_yaml

  # TODO Use some code to generate this boring code!
  @duplicate_file_count = summary['duplicateFileCount']
  @duplicate_line_count = summary['duplicateLineCount']
  @duplicate_block_count = summary['duplicateBlockCount']
  
  @total_significant_line_count = summary['totalSignificantLineCount']
  @total_raw_line_count = summary['totalRawLineCount']
  @total_file_count = summary['totalFileCount']      
  
  sets =@simian_log_yaml["simian"]["checks"][0]["sets"]
  if sets.nil?
    @sets = []
  else
    @sets = @simian_log_yaml["simian"]["checks"][0]["sets"].collect{ |original_set|
      DontRepeatYourself::SimianResults::DuplicateLinesSet.new(original_set)
    }  
  end      
end

Instance Attribute Details

#duplicate_block_countObject (readonly)

Returns the value of attribute duplicate_block_count.



3
4
5
# File 'lib/dont_repeat_yourself/simian_results.rb', line 3

def duplicate_block_count
  @duplicate_block_count
end

#duplicate_file_countObject (readonly)

Returns the value of attribute duplicate_file_count.



3
4
5
# File 'lib/dont_repeat_yourself/simian_results.rb', line 3

def duplicate_file_count
  @duplicate_file_count
end

#duplicate_line_countObject (readonly)

Returns the value of attribute duplicate_line_count.



3
4
5
# File 'lib/dont_repeat_yourself/simian_results.rb', line 3

def duplicate_line_count
  @duplicate_line_count
end

#setsObject (readonly)

Returns the value of attribute sets.



3
4
5
# File 'lib/dont_repeat_yourself/simian_results.rb', line 3

def sets
  @sets
end

#total_file_countObject (readonly)

Returns the value of attribute total_file_count.



3
4
5
# File 'lib/dont_repeat_yourself/simian_results.rb', line 3

def total_file_count
  @total_file_count
end

#total_raw_line_countObject (readonly)

Returns the value of attribute total_raw_line_count.



3
4
5
# File 'lib/dont_repeat_yourself/simian_results.rb', line 3

def total_raw_line_count
  @total_raw_line_count
end

#total_significant_line_countObject (readonly)

Returns the value of attribute total_significant_line_count.



3
4
5
# File 'lib/dont_repeat_yourself/simian_results.rb', line 3

def total_significant_line_count
  @total_significant_line_count
end

Instance Method Details

#sentence_found_x_duplicate_lines_in_y_blocks_in_z_filesObject

ignoreCurlyBraces false boolean Curly braces are ignored. ignoreIdentifiers false boolean Completely ignores all identfiers. ignoreIdentifierCase true boolean Matches identifiers irrespective of case. Eg. MyVariableName and myvariablename would both match. ignoreStrings false boolean MyVariable and myvariablewould both match. ignoreStringCase J true boolean “Hello, World” and “HELLO, WORLD” would both match. ignoreNumbers false boolean int x = 1; and int x = 576; would both match. ignoreCharacters false boolean ‘A’ and ‘Z’would both match. ignoreCharacterCase true boolean ‘A’ and ‘a’would both match. ignoreLiterals false boolean ‘A’, “one” and 27.8would all match. balanceParentheses false boolean Ensures that expressions inside parenthesis that are split across multiple physical lines are considered as one. balanceCurlyBraces false boolean Ensures that expressions inside curly braces that are split across multiple physical lines are considered as one. balanceSquareBrackets false boolean Ensures that expressions inside square brackets that are split across multiple physical lines are considered as one. Defaults to false.



46
47
48
# File 'lib/dont_repeat_yourself/simian_results.rb', line 46

def sentence_found_x_duplicate_lines_in_y_blocks_in_z_files
  "Found #{self.duplicate_line_count} duplicate lines in #{self.duplicate_block_count} blocks in #{self.duplicate_file_count} files"
end

#sentence_processed_a_total_of_x_significant_lines_in_y_filesObject



50
51
52
# File 'lib/dont_repeat_yourself/simian_results.rb', line 50

def sentence_processed_a_total_of_x_significant_lines_in_y_files
  "Processed a total of #{self.total_significant_line_count} significant (#{self.total_raw_line_count} raw) lines in #{self.total_file_count} files"
end