Class: PolishGeeks::DevTools::Commands::EmptyMethods

Inherits:
Base
  • Object
show all
Defined in:
lib/polish_geeks/dev_tools/commands/empty_methods.rb,
lib/polish_geeks/dev_tools/commands/empty_methods/file_parser.rb,
lib/polish_geeks/dev_tools/commands/empty_methods/string_refinements.rb

Overview

Validator used to check if all ‘.rb’ files don’t have empty methods

Defined Under Namespace

Modules: StringRefinements Classes: FileParser

Constant Summary collapse

DEFAULT_PATHS_TO_EXCLUDE =

Default paths which we want to exclude from analyse

%w(
  coverage
  tmp
  doc
  log
  vendor
  public
  app/assets/images
  app/assets/fonts
).freeze

Constants inherited from Base

Base::TYPES

Instance Attribute Summary collapse

Attributes inherited from Base

#output, #stored_output

Instance Method Summary collapse

Methods inherited from Base

#ensure_executable!

Instance Attribute Details

#counterObject (readonly)

Returns the value of attribute counter.



8
9
10
# File 'lib/polish_geeks/dev_tools/commands/empty_methods.rb', line 8

def counter
  @counter
end

Instance Method Details

#error_messageString

empty methods

Returns:

  • (String)

    message that should be printed when some files have



46
47
48
# File 'lib/polish_geeks/dev_tools/commands/empty_methods.rb', line 46

def error_message
  "Following files contains blank methods: \n#{output.join("\n")}\n"
end

#executeObject

Executes this command and set output and counter variables



23
24
25
26
27
28
29
30
31
32
# File 'lib/polish_geeks/dev_tools/commands/empty_methods.rb', line 23

def execute
  @output = []
  @counter = 0

  files_to_analyze.each do |file|
    @counter += 1
    empty_methods = FileParser.new(file).find_empty_methods
    @output << sanitize(file) + " lines #{empty_methods}" unless empty_methods.empty?
  end
end

#labelString

Returns default label for this command.

Returns:

  • (String)

    default label for this command



40
41
42
# File 'lib/polish_geeks/dev_tools/commands/empty_methods.rb', line 40

def label
  "Empty methods: #{counter} files checked"
end

#valid?Boolean

Returns true if none of the files include any empty methods.

Returns:

  • (Boolean)

    true if none of the files include any empty methods



35
36
37
# File 'lib/polish_geeks/dev_tools/commands/empty_methods.rb', line 35

def valid?
  output.empty?
end