Skip to content

Instantly share code, notes, and snippets.

@juno
Last active June 9, 2017 12:48
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juno/7539919 to your computer and use it in GitHub Desktop.
Save juno/7539919 to your computer and use it in GitHub Desktop.
Code statistics for qnyp.com application at Nov 19, 2013.

rake about

$ rake about
About your application's environment
Ruby version              2.0.0 (x86_64-darwin12.4.0)
RubyGems version          2.1.9
Rack version              1.5
Rails version             4.0.1
JavaScript Runtime        Node.js (V8)
Active Record version     4.0.1
Action Pack version       4.0.1
Action Mailer version     4.0.1
Active Support version    4.0.1
Middleware                Rack::MiniProfiler, Raven::Rack, SearchSuggestions, Rack::Sendfile, ActionDispatch::Static, Rack::Lock, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007fc5d9dd1f48>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, BetterErrors::Middleware, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag, Bullet::Rack, Xray::Middleware
Application root          /Users/juno/src/ural
Environment               development
Database adapter          postgresql
Database schema version   20131016090528

rake stats

$ rake stats
+----------------------+-------+-------+---------+---------+-----+-------+
| Name                 | Lines |   LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers          |  2259 |  1355 |      43 |     203 |   4 |     4 |
| Helpers              |   669 |   272 |       0 |      40 |   0 |     4 |
| Models               |  3360 |  1242 |      21 |     167 |   7 |     5 |
| Mailers              |   150 |    82 |       4 |      10 |   2 |     6 |
| Javascripts          |   394 |   195 |       3 |      41 |  13 |     2 |
| Libraries            |   861 |   448 |      14 |      63 |   4 |     5 |
| Helper tests         |     0 |     0 |       0 |       0 |   0 |     0 |
| Mailer tests         |     0 |     0 |       0 |       0 |   0 |     0 |
| Integration tests    |     0 |     0 |       0 |       0 |   0 |     0 |
| Controller specs     |  5933 |  4912 |       0 |       2 |   0 |  2454 |
| Feature specs        |  1290 |   945 |       0 |       4 |   0 |   234 |
| Helper specs         |   457 |   352 |       0 |       0 |   0 |     0 |
| Lib specs            |   692 |   552 |       0 |       2 |   0 |   274 |
| Mailer specs         |    69 |    56 |       0 |       0 |   0 |     0 |
| Middleware specs     |    43 |    35 |       0 |       0 |   0 |     0 |
| Model specs          |  4840 |  3914 |       0 |       0 |   0 |     0 |
| Routing specs        |   548 |   417 |       0 |       0 |   0 |     0 |
| Service specs        |  1032 |   808 |       0 |       4 |   0 |   200 |
| Validator specs      |    85 |    69 |       1 |       0 |   0 |     0 |
| Worker specs         |    32 |    23 |       0 |       0 |   0 |     0 |
+----------------------+-------+-------+---------+---------+-----+-------+
| Total                | 22714 | 15677 |      86 |     536 |   6 |    27 |
+----------------------+-------+-------+---------+---------+-----+-------+
  Code LOC: 3594     Test LOC: 12083     Code to Test Ratio: 1:3.4

rake notes

$ rake notes
app/controllers/application_controller.rb:
  * [  8] [TODO] プライベートベータ終了時に削除する

app/controllers/checkins_controller.rb:
  * [ 18] [TODO] new_commentにリネームする

app/controllers/home_controller.rb:
  * [ 15] [TODO] リファクタリング

app/controllers/users/comments_controller.rb:
  * [  9] [TODO] thingがEpisode以外になった場合にtitleがロードエラーとなるので要リファクタリング

app/controllers/users_controller.rb:
  * [ 13] [TODO] thingがEpisode以外だった場合にtitleをロードできなくなるので要リファクタリング

app/helpers/title_helper.rb:
  * [  4] [TODO] 最終的にこの定数が必要ないようにする

app/models/checkin.rb:
  * [ 58] [TODO] authorに変更する

app/models/invitation.rb:
  * [ 33] [TODO] I18n
  * [ 39] [TODO] I18n

app/models/person.rb:
  * [ 85] [TODO] RANDOM()を使わないようにする

app/models/title.rb:
  * [104] [TODO] 管理画面でのエピソード編集方式を変更して nested_attributes を使わないようにする

app/models/user.rb:
  * [167] [TODO] Deprecated
  * [318] [TODO] DBに格納する
  * [339] [TODO] 定数として抽出する

app/services/title_thumbnail_service.rb:
  * [ 27] [TODO] この結果は頻繁に変わるものではないので一定期間キャッシュするようにする
  * [ 41] [TODO] 即時性の必要な情報ではないので、一定期間キャッシュするようにする

app/views/notifications/_notification.html.erb:
  * [  2] [TODO] ビューからモデルへロジックを移す

app/views/shared/_checkin_timeline.html.erb:
  * [  1] [TODO] _checkin.html.erbと統合

app/views/shared/_post.html.erb:
  * [ 31] [TODO] BEM

app/views/titles/show.html.erb:
  * [ 51] [TODO] beforeでcontent

config/initializers/disable_view_paths_fallback.rb:
  * [  1] [TODO] 新デザインへの移行が完了したらこのファイルは削除する

config/routes.rb:
  * [ 46] [TODO] required_invitation? 機能フラグを無効にする際に有効にする
  * [ 64] [TODO] 旧デザイン用のルートなので削除する
  * [ 67] [TODO] 旧デザイン用のルートなので削除する
  * [ 71] [TODO] 旧デザイン用のルートなので削除する
  * [ 74] [TODO] 旧デザイン用のルートなので削除する
  * [ 81] [TODO] 旧デザイン用のルートなので削除する
  * [ 93] [TODO] 旧デザイン用のルートなので削除する
  * [106] [TODO] リファクタリング

lib/tasks/wikipedia_csv.rake:
  * [121] [TODO] レーベンシュタイン距離で探す

Cane

$ bundle exec cane

Methods exceeded maximum allowed ABC complexity (2):

  app/controllers/admin/versions_controller.rb  VersionsController#set_versionable  17
  app/controllers/titles_controller.rb          TitlesController#show               16

Total Violations: 2

Rubocop

$ bundle exec rubocop app lib
Inspecting 148 files
.......................................C........C...C.......C..........C..................C...C...C..............CC....C..CC............CCC.CCCCCCCC

Offences:

app/controllers/titles_controller.rb:89:3: C: Method has too many lines. [14/10]
  def track_title_search_event(user, keyword, result_count)
  ^^^
app/controllers/users_controller.rb:11:5: C: Provide an exception class and message as arguments to fail.
    fail ActiveRecord::RecordNotFound.new unless @user
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/helpers/application_helper.rb:67:19: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    class_value = "thumbnail-crop__img"
                  ^^^^^^^^^^^^^^^^^^^^^
app/helpers/title_helper.rb:72:3: C: Method has too many lines. [13/10]
  def title_thumbnail_crop_image_url(title, crop_type = :silver)
  ^^^
app/helpers/title_helper.rb:95:3: C: Method has too many lines. [18/10]
  def title_thumbnail_highlight(titles)
  ^^^
app/models/checkin.rb:21:1: C: Class definition is too long. [113/100]
class Checkin < ActiveRecord::Base
^^^^^
app/models/search_suggestion.rb:26:3: C: Method has too many lines. [13/10]
  def self.titles_for(term)
  ^^^
app/models/title.rb:80:1: C: Class definition is too long. [122/100]
class Title < ActiveRecord::Base
^^^^^
app/models/user.rb:15:1: C: Class definition is too long. [196/100]
class User < ActiveRecord::Base
^^^^^
app/services/casting_importer.rb:134:7: C: Method has too many lines. [17/10]
      def build_casting(cols)
      ^^^
app/services/casting_importer.rb:142:9: C: Provide an exception class and message as arguments to fail.
        fail InvalidPersonError.new(cols) unless person
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/casting_importer.rb:154:9: C: Provide an exception class and message as arguments to fail.
        fail CastingAlreadyExists.new(casting) if casting
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/casting_importer.rb:169:9: C: Provide an exception class and message as arguments to fail.
        fail InvalidCharacterError.new(cols) unless character
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/character_importer.rb:47:5: C: Method has too many lines. [12/10]
    def import_row(row, report)
    ^^^
app/services/character_importer.rb:91:7: C: Method has too many lines. [12/10]
      def populate_character(row)
      ^^^
app/services/character_importer.rb:119:7: C: Cyclomatic complexity for find_character is too high. [7/6]
      def find_character(cols)
      ^^^
app/services/character_importer.rb:122:11: C: Provide an exception class and message as arguments to fail.
          fail CharacterNameAlreadyExists.new(character)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/episode_checkin_matrix_builder.rb:52:5: C: Method has too many lines. [14/10]
    def build_episodes_with_user_checkins_count(title, user)
    ^^^
app/services/person_importer.rb:118:7: C: Cyclomatic complexity for parse_row is too high. [8/6]
      def parse_row(row)
      ^^^
app/services/string_normalizer.rb:28:3: C: Method has too many lines. [11/10]
  def self.normalize_name(value)
  ^^^
app/services/string_normalizer.rb:52:3: C: Method has too many lines. [11/10]
  def self.normalize_search_text(value)
  ^^^
lib/clear_empty_attributes.rb:7:1: C: Extra blank line detected at body beginning.
lib/clear_empty_attributes.rb:27:1: C: Extra blank line detected at body end.
lib/exceptions.rb:6:1: C: Extra blank line detected at body beginning.
lib/exceptions.rb:21:1: C: Extra blank line detected at body end.
lib/japanese_quarter.rb:3:1: C: Extra blank line detected at body beginning.
lib/japanese_quarter.rb:23:1: C: Extra blank line detected at body end.
lib/syoboi_title/subtitle_importer.rb:5:1: C: Extra blank line detected at body beginning.
lib/syoboi_title/subtitle_importer.rb:8:1: C: Extra blank line detected at body beginning.
lib/syoboi_title/subtitle_importer.rb:118:1: C: Extra blank line detected at body end.
lib/syoboi_titles/xml_generator.rb:8:1: C: Extra blank line detected at body beginning.
lib/syoboi_titles/xml_generator.rb:65:30: C: Use || instead of or.
      File.exist?(@xml_path) or File.exist?(@test_xml_path)
                             ^^
lib/syoboi_titles/xml_generator.rb:132:1: C: Extra blank line detected at body end.
lib/syoboi_titles/xml_importer/syoboi_doc.rb:7:1: C: Extra blank line detected at body beginning.
lib/syoboi_titles/xml_importer/syoboi_doc.rb:50:1: C: Extra blank line detected at body end.
lib/syoboi_titles/xml_importer/title_node.rb:6:1: C: Extra blank line detected at body beginning.
lib/syoboi_titles/xml_importer/title_node.rb:38:7: C: Use 2 (not 3) spaces for indentation.
         Date.new(@first_end_year, @first_end_month, 1).end_of_month
      ^^^
lib/syoboi_titles/xml_importer/title_node.rb:42:1: C: Extra blank line detected.
lib/syoboi_titles/xml_importer/title_node.rb:84:5: C: Method has too many lines. [13/10]
    def parse_subtitles
    ^^^
lib/syoboi_titles/xml_importer/title_node.rb:99:1: C: Extra blank line detected at body end.
lib/syoboi_titles/xml_importer.rb:7:1: C: Extra blank line detected at body beginning.
lib/syoboi_titles/xml_importer.rb:27:1: C: Extra blank line detected.
lib/syoboi_titles/xml_importer.rb:66:7: C: Method has too many lines. [11/10]
      def save_title_node(title_node)
      ^^^
lib/syoboi_titles/xml_importer.rb:73:51: C: Favor sprintf over String#%.
        info("%4s %5d TID:%4d #{title_node.name}" % ['NEW', @current_title_index, title_node.syoboi_tid])
                                                  ^
lib/syoboi_titles/xml_importer.rb:105:7: C: Method has too many lines. [14/10]
      def save_title_node_subtitle(subtitle)
      ^^^
lib/syoboi_titles/xml_importer.rb:193:51: C: Favor sprintf over String#%.
        info("%4s %5d TID:%4d #{title_node.name}" % ['', @current_title_index, syoboi_tid])
                                                  ^
lib/syoboi_titles/xml_importer.rb:196:1: C: Extra blank line detected at body end.
lib/syoboi_titles.rb:1:1: C: Missing top-level module documentation comment.
module SyoboiTitles
^^^^^^
lib/system_notification/hip_chat.rb:4:1: C: Extra blank line detected at body beginning.
lib/system_notification/hip_chat.rb:24:1: C: Extra blank line detected at body beginning.
lib/system_notification/hip_chat.rb:49:17: C: Redundant `self` detected.
      hipchat = self.new
                ^^^^^^^^
lib/system_notification/hip_chat.rb:90:5: C: Method has too many lines. [15/10]
    def load_options(options = {})
    ^^^
lib/system_notification/hip_chat.rb:100:9: C: Use `fail` instead of `raise` to signal exceptions.
        raise RuntimeError, "HipChat needs #{missing_options.to_sentence} to send!"
        ^^^^^
lib/system_notification/hip_chat.rb:100:15: C: Redundant `RuntimeError` argument can be removed.
        raise RuntimeError, "HipChat needs #{missing_options.to_sentence} to send!"
              ^^^^^^^^^^^^
lib/system_notification/hip_chat.rb:109:1: C: Extra blank line detected at body end.
lib/system_notification/hip_chat.rb:111:1: C: Extra blank line detected at body end.
lib/system_notification/title_message.rb:2:1: C: Extra blank line detected at body beginning.
lib/system_notification/title_message.rb:13:1: C: Extra blank line detected at body beginning.
lib/system_notification/title_message.rb:18:5: C: Method has too many lines. [15/10]
    def original_run_to_unset
    ^^^
lib/system_notification/title_message.rb:53:1: C: Extra blank line detected at body end.
lib/system_notification/title_message.rb:55:1: C: Extra blank line detected at body end.

148 files inspected, 61 offences detected

Magic numbers in sources

$ bundle exec mago app lib
app/controllers/admin/characters_controller.rb:16 detected magic number 100
app/controllers/admin/latest_created_titles_controller.rb:12 detected magic number 100
app/controllers/admin/latest_updated_titles_controller.rb:12 detected magic number 100
app/controllers/admin/people_controller.rb:17 detected magic number 100
app/controllers/admin/people_controller.rb:19 detected magic number 100
app/controllers/admin/staff_roles_controller.rb:13 detected magic number 100
app/controllers/admin/titles_controller.rb:19 detected magic number 100
app/controllers/admin/titles_controller.rb:21 detected magic number 100
app/controllers/admin/users_controller.rb:10 detected magic number 100
app/controllers/users/matrix_controller.rb:32 detected magic number 4
app/controllers/users/matrix_controller.rb:33 detected magic number 4
app/controllers/users/matrix_controller.rb:33 detected magic number 2
app/controllers/zendesk_session_controller.rb:18 detected magic number 36
app/controllers/zendesk_session_controller.rb:18 detected magic number 64
app/controllers/zendesk_session_controller.rb:18 detected magic number 36
app/helpers/character_helper.rb:12 detected magic number 25
app/helpers/emoji_helper.rb:21 detected magic number 20
app/helpers/title_helper.rb:77 detected magic number 354
app/helpers/title_helper.rb:77 detected magic number 500
app/helpers/title_helper.rb:79 detected magic number 354
app/helpers/title_helper.rb:79 detected magic number 354
app/helpers/title_helper.rb:81 detected magic number 354
app/helpers/title_helper.rb:81 detected magic number 230
app/helpers/title_helper.rb:83 detected magic number 354
app/helpers/title_helper.rb:83 detected magic number 120
app/helpers/title_helper.rb:98 detected magic number 5
app/helpers/title_helper.rb:103 detected magic number 100
app/helpers/title_helper.rb:104 detected magic number 100
app/helpers/title_helper.rb:139 detected magic number 640
app/helpers/title_helper.rb:139 detected magic number 500
app/middlewares/search_suggestions.rb:23 detected magic number 200
app/models/character.rb:35 detected magic number 255
app/models/character.rb:38 detected magic number 255
app/models/character.rb:40 detected magic number 255
app/models/checkin.rb:81 detected magic number 10
app/models/concerns/title_finders.rb:30 detected magic number 3
app/models/concerns/title_finders.rb:37 detected magic number 3
app/models/concerns/title_scoring.rb:51 detected magic number 2
app/models/concerns/title_scoring.rb:60 detected magic number 2
app/models/episode.rb:75 detected magic number 255
app/models/episode.rb:77 detected magic number 255
app/models/episode.rb:108 detected magic number 10
app/models/person.rb:71 detected magic number 20
app/models/person.rb:174 detected magic number -1
app/models/rating.rb:33 detected magic number 10
app/models/search_suggestion.rb:31 detected magic number 20
app/models/staff_position.rb:32 detected magic number 255
app/models/staff_role.rb:18 detected magic number 255
app/models/staff_role.rb:22 detected magic number 255
app/models/statistics.rb:109 detected magic number 2
app/models/statistics.rb:116 detected magic number 2
app/models/statistics.rb:123 detected magic number 2
app/models/title.rb:137 detected magic number 255
app/models/title.rb:154 detected magic number 20
app/models/title.rb:175 detected magic number 2
app/models/title.rb:177 detected magic number 2
app/models/title.rb:323 detected magic number 100
app/models/title.rb:365 detected magic number 12
app/models/user.rb:194 detected magic number 2
app/models/user.rb:195 detected magic number 100
app/models/user.rb:207 detected magic number 2
app/services/checkin_achievement_service.rb:26 detected magic number 2
app/services/checkin_achievement_service.rb:29 detected magic number 24
app/services/checkin_achievement_service.rb:72 detected magic number 24
app/services/person_importer.rb:122 detected magic number 2
app/services/person_importer.rb:123 detected magic number 3
app/services/person_importer.rb:124 detected magic number 4
app/services/person_importer.rb:125 detected magic number 5
app/services/person_importer.rb:126 detected magic number 6
app/services/person_importer.rb:126 detected magic number 6
app/uploaders/avatar_uploader.rb:10 detected magic number 600
app/uploaders/avatar_uploader.rb:10 detected magic number 600
app/uploaders/avatar_uploader.rb:14 detected magic number 320
app/uploaders/avatar_uploader.rb:14 detected magic number 320
app/uploaders/avatar_uploader.rb:18 detected magic number 160
app/uploaders/avatar_uploader.rb:18 detected magic number 160
app/uploaders/avatar_uploader.rb:22 detected magic number 80
app/uploaders/avatar_uploader.rb:22 detected magic number 80
app/uploaders/avatar_uploader.rb:26 detected magic number 40
app/uploaders/avatar_uploader.rb:26 detected magic number 40
lib/syoboi_titles/xml_importer/title_node.rb:90 detected magic number 2
lib/system_notification/title_message.rb:23 detected magic number 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment