This is a fasterer extension which allows to scan GitHub repo using GitHub API.
Fasterer-github will analyze your code and suggest faster ruby idioms. Read more about ruby idoms here
Add this line to your application's Gemfile:
gem'fasterer-github'And then execute:
$ bundle
Or install it yourself as:
$ gem install fasterer-github
Github api rate limit for unauthenticated requests is 60 request per hour. Fortunately, authenticated requests get a higher rate limit, which allows to make up to 5,000 requests per hour.
You can use configure block to provide access_token:
Fasterer::Github.configuredo |config|
config.access_token='YOUR_GITHUB_ACCESS_TOKEN'endInstead of access_token, you can also add client_id and client_secret:
Fasterer::Github.configuredo |config|
config.client_id='YOUR_GITHUB_CLIENT_ID'config.client_secret='YOUR_GITHUB_CLIENT_SECRET'endAdditional configuration can be done using .fasterer.yml file, which has to be placed in the root folder of your project.
Possible options:
- turn off speed suggestions
- blacklist files or complete folder paths
speedups:
parallel_assignment: falserescue_vs_respond_to: truemodule_eval: trueshuffle_first_vs_sample: truefor_loop_vs_each: trueeach_with_index_vs_while: falsemap_flatten_vs_flat_map: truereverse_each_vs_reverse_each: trueselect_first_vs_detect: truesort_vs_sort_by: truefetch_with_argument_vs_block: truekeys_each_vs_each_key: truehash_merge_bang_vs_hash_brackets: trueblock_vs_symbol_to_proc: trueproc_call_vs_yield: truegsub_vs_tr: trueselect_last_vs_reverse_detect: truegetter_vs_attr_reader: truesetter_vs_attr_writer: trueexclude_paths:
- 'vendor/'
- 'db/schema.rb'To scan whole repo, run:
Fasterer::Github.scan('owner','repo')Or scan specific file:
Fasterer::Github.scan('owner','repo','lib/fasterer-github.rb')$ Fasterer::Github.scan('owner','repo','path/to/file.rb'){:repo_owner=>'owner',:repo_name=>'repo',:fasterer_offences=>{:hash_merge_bang_vs_hash_brackets=>[{:path=>"https://api.github.com/repos/owner/repo/contents/path/to/file.rb?ref=master",:lines=>[10,17,19]}]},:errors=>[],:api_errors=>[]}Example output when parser encounters some error and api returns error code:
{:repo_owner=>'owner',:repo_name=>'repo',:fasterer_offences=>{},:errors=>[{path: 'path/to/file.rb'}],:api_errors=>[{code: 404,msg_body: 'some message from github api',path: 'path/to/file.rb'}]}Bug reports and pull requests are welcome on GitHub at https://github.com/caspg/fasterer-github.
The gem is available as open source under the terms of the MIT License.