Class: RuboCop::Cop::Isucon::Sqlite3::SelectAsterisk

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
Mixin::SelectAsteriskMethods, Mixin::Sqlite3ExecuteMethods
Defined in:
lib/rubocop/cop/isucon/sqlite3/select_asterisk.rb

Overview

Note:

If Database isn't configured, auto-correct will not be available. (Only offense detection can be used)

Note:

This cop replaces SELECT * with a SELECT by the columns present in the table (e.g. SELECT id, name), but does not check whether the columns are actually used. Please manually delete unused columns after auto corrected

Avoid SELECT * in db.execute

Examples:

# bad
db.execute('SELECT * FROM users')

# bad
db.execute('SELECT users.* FROM users')

# good
db.execute('SELECT id, name FROM users')

# good
db.execute('SELECT users.id, users.name FROM users')

Constant Summary

Constants included from Mixin::SelectAsteriskMethods

Mixin::SelectAsteriskMethods::MSG, Mixin::SelectAsteriskMethods::TODO

Constants included from Mixin::Sqlite3ExecuteMethods

Mixin::Sqlite3ExecuteMethods::NON_STRING_WARNING_MSG

Method Summary

Methods included from Mixin::SelectAsteriskMethods

#on_send

Methods included from Mixin::DatabaseMethods

#connection, #enabled_database?, #find_table_name_from_column_name

Methods included from Mixin::Sqlite3ExecuteMethods

#find_xquery, #with_db_query

Methods included from Mixin::OffenceLocationMethods

#offense_location