Class: Neetob::CLI::Code::Audit
- Inherits:
-
Github::Base
- Object
- Base
- Github::Base
- Neetob::CLI::Code::Audit
- Defined in:
- lib/neetob/cli/code/audit.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#apps ⇒ Object
Returns the value of attribute apps.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
Attributes inherited from Github::Base
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(apps, sandbox = false) ⇒ Audit
constructor
A new instance of Audit.
- #run ⇒ Object
Methods included from Utils
#camel_case_to_slug, #is_upper?, #symbolize_keys
Constructor Details
#initialize(apps, sandbox = false) ⇒ Audit
Returns a new instance of Audit.
11 12 13 14 15 |
# File 'lib/neetob/cli/code/audit.rb', line 11 def initialize(apps, sandbox = false) super() @apps = apps @sandbox = sandbox end |
Instance Attribute Details
#apps ⇒ Object
Returns the value of attribute apps.
9 10 11 |
# File 'lib/neetob/cli/code/audit.rb', line 9 def apps @apps end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
9 10 11 |
# File 'lib/neetob/cli/code/audit.rb', line 9 def sandbox @sandbox end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/neetob/cli/code/audit.rb', line 17 def run matching_apps = find_all_matching_apps_or_repos(apps, :github, sandbox) ui.info( "\nListing apps and their tables that doesn't have uuid as primary key type:-", print_to_audit_log: false) has_found_tables_without_uuid = false data = [] matching_apps.each do |app| begin db_schema = Base64.decode64(client.contents(app, path: "./db/schema.rb").content) tables_without_uuid = find_tables_without_uuid_as_primary_key(db_schema).compact if !tables_without_uuid.nil? has_found_tables_without_uuid = true print_app_and_tables(app, tables_without_uuid) end unique_email_index_result = verify_unique_email_index(db_schema) data << { tables_without_uuid:, unique_email_index_result: } rescue Octokit::NotFound ui.error("There is no \"db/schema.rb\" file in the \"#{app}\" app.") data << { error: "There is no \"db/schema.rb\" file in the \"#{app}\" app." } rescue StandardError => e ExceptionHandler.new(e).process end end ui.info( "No apps found to have tables without uuid as primary key type", print_to_audit_log: false) if !has_found_tables_without_uuid if Thread.current[:audit_mode] data end end |