Class: RuboCop::Cop::Isucon::Mysql2::SelectAsterisk

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
RuboCop::Cop::Isucon::Mixin::Mysql2XqueryMethods, RuboCop::Cop::Isucon::Mixin::SelectAsteriskMethods
Defined in:
lib/rubocop/cop/isucon/mysql2/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.xquery

Examples:

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

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

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

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

Constant Summary

Constants included from RuboCop::Cop::Isucon::Mixin::SelectAsteriskMethods

RuboCop::Cop::Isucon::Mixin::SelectAsteriskMethods::MSG, RuboCop::Cop::Isucon::Mixin::SelectAsteriskMethods::TODO

Constants included from RuboCop::Cop::Isucon::Mixin::Mysql2XqueryMethods

RuboCop::Cop::Isucon::Mixin::Mysql2XqueryMethods::NON_STRING_WARNING_MSG

Method Summary

Methods included from RuboCop::Cop::Isucon::Mixin::SelectAsteriskMethods

#on_send

Methods included from RuboCop::Cop::Isucon::Mixin::DatabaseMethods

#connection, #enabled_database?, #find_table_name_from_column_name

Methods included from RuboCop::Cop::Isucon::Mixin::Mysql2XqueryMethods

#find_xquery, #with_db_query

Methods included from RuboCop::Cop::Isucon::Mixin::OffenceLocationMethods

#offense_location