Class: RailsDoctor::Checks::RailsChecks

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_doctor/checks/rails_checks.rb

Constant Summary collapse

NAME =
"rails_checks"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project:, config:, runner:, profile:, changed_files: []) ⇒ RailsChecks

Returns a new instance of RailsChecks.



10
11
12
13
14
15
16
# File 'lib/rails_doctor/checks/rails_checks.rb', line 10

def initialize(project:, config:, runner:, profile:, changed_files: [])
  @project = project
  @config = config
  @runner = runner
  @profile = profile
  @changed_files = changed_files
end

Instance Attribute Details

#changed_filesObject (readonly)

Returns the value of attribute changed_files.



8
9
10
# File 'lib/rails_doctor/checks/rails_checks.rb', line 8

def changed_files
  @changed_files
end

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/rails_doctor/checks/rails_checks.rb', line 8

def config
  @config
end

#profileObject (readonly)

Returns the value of attribute profile.



8
9
10
# File 'lib/rails_doctor/checks/rails_checks.rb', line 8

def profile
  @profile
end

#projectObject (readonly)

Returns the value of attribute project.



8
9
10
# File 'lib/rails_doctor/checks/rails_checks.rb', line 8

def project
  @project
end

#runnerObject (readonly)

Returns the value of attribute runner.



8
9
10
# File 'lib/rails_doctor/checks/rails_checks.rb', line 8

def runner
  @runner
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/rails_doctor/checks/rails_checks.rb', line 22

def available?
  project.rails_app?
end

#install_guidanceObject



30
31
32
# File 'lib/rails_doctor/checks/rails_checks.rb', line 30

def install_guidance
  "Run Rails Doctor from the root of a Rails 7.1+ application."
end

#nameObject



18
19
20
# File 'lib/rails_doctor/checks/rails_checks.rb', line 18

def name
  NAME
end

#runObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rails_doctor/checks/rails_checks.rb', line 34

def run
  findings = []
  findings.concat(missing_foreign_key_indexes)
  findings.concat(missing_unique_indexes)
  findings.concat(route_action_view_findings)
  findings.concat(large_artifact_findings)
  findings.concat(todo_density_findings)
  findings.concat(missing_test_counterparts)
  findings.concat(coverage_gap_findings)

  {
    tool_run: ToolRun.new(
      name: name,
      available: true,
      skipped: false,
      exit_status: 0,
      metadata: { checks: %w[indexes uniqueness routes views size todos tests coverage-gaps] }
    ),
    findings: findings
  }
end

#unavailable_reasonObject



26
27
28
# File 'lib/rails_doctor/checks/rails_checks.rb', line 26

def unavailable_reason
  "This does not look like a Rails app."
end