Skip to content

Instantly share code, notes, and snippets.

@shoaibmalik786
Created March 11, 2022 08:43
Show Gist options
  • Save shoaibmalik786/396af177b014d9e6167557f5676f1749 to your computer and use it in GitHub Desktop.
Save shoaibmalik786/396af177b014d9e6167557f5676f1749 to your computer and use it in GitHub Desktop.

Audit Report

Specs

  • controllers are not covered with rspecs
  • gem 'simplecov' is added in Gemfile but is not correctly implemented and it is not generating the html file to check the specs coverage.

Code audit

  • Query should not be written on views. check on app/views/component/gupdates_index/_index.html.erb
  • There is an examples controller which is of no use, we should not keep the redundant code.
  • provide_names_and_ids method is not being used anywhere in the code which is defined in concern inside model
  • In routes.rb, api/v1 should be inside namespace instead of scope. The reason if we would have to build v2 version of the API, the API endpoint url for v2 wouldn't be updated to use on client side. and define { format: :json } as globally with namespace instead of defining for individual routes. -Not sure why do we have a separate controller for current_user. current_user is a member resource, so there is no meaning to define the index action for just getting current_user, instead I would prefer to define show action and in routes.rb resource :current_user instead of resources :current_user
  • I see that jquery.min file is placed inside public folder, which is not good for security reasons. we should add jquery package with yarn or npm. Step1: yarn add jquery Step2: create file app/javascript/add_jquery.js and put below content
      import jquery from 'jquery'
      window.jQuery = jquery
      window.$ = jquery
    
    Step3: Add below line to your app/javascript/application.js
    import './add_jquery'
    
  • Good to add gem annotate to have the schema of the table in models.
  • why are we not using polymorphic association in game
    belongs_to :publisher
    belongs_to :subgenre
    belongs_to :game_theme
    belongs_to :game_setting
    belongs_to :game_art_style
    belongs_to :game_camera_pov
    
    game.rb model is associated to many different models, so it's better to keep it simple with polymorphic association.
  • Readme.md file should have the instructions to setup the repo like ruby version, dependencicy if any and caveats if any.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment