repo_analyzer 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +103 -0
- data/.circleci/setup-rubygems.sh +3 -0
- data/.editorconfig +24 -0
- data/.gitignore +9 -0
- data/.rspec +3 -0
- data/.rubocop.yml +505 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +320 -0
- data/Guardfile +12 -0
- data/LICENSE.txt +21 -0
- data/README.md +165 -0
- data/Rakefile +10 -0
- data/app/assets/config/repo_analyzer_manifest.js +1 -0
- data/app/assets/images/repo_analyzer/.keep +0 -0
- data/app/assets/stylesheets/repo_analyzer/application.css +15 -0
- data/app/clients/repo_analyzer/github_client.rb +31 -0
- data/app/controllers/repo_analyzer/application_controller.rb +4 -0
- data/app/extractors/repo_analyzer/brakeman_extractor.rb +33 -0
- data/app/extractors/repo_analyzer/circleci_extractor.rb +46 -0
- data/app/extractors/repo_analyzer/github_extractor.rb +64 -0
- data/app/extractors/repo_analyzer/power_types_extractor.rb +21 -0
- data/app/extractors/repo_analyzer/project_config_extractor.rb +53 -0
- data/app/extractors/repo_analyzer/project_info_extractor.rb +20 -0
- data/app/extractors/repo_analyzer/project_versions_extractor.rb +80 -0
- data/app/extractors/repo_analyzer/rails_best_practices_extractor.rb +36 -0
- data/app/extractors/repo_analyzer/rubocop_extractor.rb +74 -0
- data/app/extractors/repo_analyzer/tests_info_extractor.rb +87 -0
- data/app/helpers/repo_analyzer/application_helper.rb +4 -0
- data/app/jobs/repo_analyzer/application_job.rb +4 -0
- data/app/jobs/repo_analyzer/extract_project_info_job.rb +35 -0
- data/app/jobs/repo_analyzer/post_extracted_info_job.rb +28 -0
- data/app/mailers/repo_analyzer/application_mailer.rb +6 -0
- data/app/models/repo_analyzer/application_record.rb +5 -0
- data/app/utils/output_utils.rb +10 -0
- data/app/values/repo_analyzer/project_data_bridge.rb +48 -0
- data/app/views/layouts/repo_analyzer/application.html.erb +15 -0
- data/bin/rails +25 -0
- data/config/routes.rb +2 -0
- data/lib/generators/repo_analyzer/install/USAGE +5 -0
- data/lib/generators/repo_analyzer/install/install_generator.rb +19 -0
- data/lib/generators/repo_analyzer/install/templates/initializer.rb +2 -0
- data/lib/repo_analyzer/engine.rb +15 -0
- data/lib/repo_analyzer/example_class.rb +7 -0
- data/lib/repo_analyzer/version.rb +3 -0
- data/lib/repo_analyzer.rb +48 -0
- data/lib/tasks/repo_analyzer_tasks.rake +7 -0
- data/repo_analyzer.gemspec +42 -0
- data/spec/assets/test_project/README.md +1 -0
- data/spec/assets/test_project/app/commands/some_comand.rb +0 -0
- data/spec/assets/test_project/app/javascript/src/component.spec.js +0 -0
- data/spec/assets/test_project/app/javascript/src/components/component.spec.js +0 -0
- data/spec/assets/test_project/app/observers/some_observer.rb +0 -0
- data/spec/assets/test_project/old_circleci_config.yml +21 -0
- data/spec/assets/test_project/spec/commands/command1_spec.rb +0 -0
- data/spec/assets/test_project/spec/commands/command2_spec.rb +0 -0
- data/spec/assets/test_project/spec/integration/integration1_spec.rb +0 -0
- data/spec/assets/test_project/spec/system/system_test_spec.rb +0 -0
- data/spec/assets/test_project/valid_circleci_config.yml +152 -0
- data/spec/assets/test_project/valid_gem_gemfile_lock +14 -0
- data/spec/assets/test_project/valid_gemfile_lock +684 -0
- data/spec/assets/test_project/valid_makefile +35 -0
- data/spec/assets/test_project/valid_package_json +84 -0
- data/spec/assets/test_project/valid_package_json_without_vue +74 -0
- data/spec/assets/test_project/valid_rubocop_rules.yml +54 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/javascript/packs/application.js +15 -0
- data/spec/dummy/app/jobs/application_job.rb +7 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +33 -0
- data/spec/dummy/config/application.rb +38 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +81 -0
- data/spec/dummy/config/environments/production.rb +120 -0
- data/spec/dummy/config/environments/test.rb +59 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +12 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +8 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/permissions_policy.rb +11 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +43 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/config.ru +6 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/extractors/brakeman_extractor_spec.rb +73 -0
- data/spec/extractors/circleci_extractor_spec.rb +45 -0
- data/spec/extractors/github_extractor_spec.rb +77 -0
- data/spec/extractors/power_types_extractor_spec.rb +18 -0
- data/spec/extractors/project_config_extractor_spec.rb +52 -0
- data/spec/extractors/project_versions_extractor_spec.rb +63 -0
- data/spec/extractors/rails_best_practices_extractor_spec.rb +53 -0
- data/spec/extractors/rubocop_extractor_spec.rb +113 -0
- data/spec/extractors/tests_info_extractor_spec.rb +65 -0
- data/spec/fixtures/files/image.png +0 -0
- data/spec/fixtures/files/video.mp4 +0 -0
- data/spec/jobs/repo_analyzer/extract_project_info_job_spec.rb +50 -0
- data/spec/jobs/repo_analyzer/post_extracted_info_job_spec.rb +52 -0
- data/spec/rails_helper.rb +42 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/support/repo_analyzer_helpers.rb +37 -0
- metadata +518 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
require "brakeman"
|
2
|
+
require "octokit"
|
3
|
+
require "rails_best_practices"
|
4
|
+
require "rubocop"
|
5
|
+
require "rubocop-performance"
|
6
|
+
require "rubocop-platanus"
|
7
|
+
require "rubocop-rails"
|
8
|
+
require "rubocop-rspec"
|
9
|
+
|
10
|
+
require "repo_analyzer/engine"
|
11
|
+
|
12
|
+
module RepoAnalyzer
|
13
|
+
extend self
|
14
|
+
|
15
|
+
# You can add, in this module, your own configuration options as in the example below...
|
16
|
+
#
|
17
|
+
# attr_writer :my_option
|
18
|
+
#
|
19
|
+
# def my_option
|
20
|
+
# return "Default Value" unless @my_option
|
21
|
+
# @my_option
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# Then, you can customize the default behaviour (typically in a Rails initializer) like this:
|
25
|
+
#
|
26
|
+
# RepoAnalyzer.setup do |config|
|
27
|
+
# config.root_url = "Another value"
|
28
|
+
# end
|
29
|
+
|
30
|
+
attr_writer :github_personal_token, :post_extracted_info_endpoint
|
31
|
+
|
32
|
+
def github_personal_token
|
33
|
+
return ENV["GITHUB_PERSONAL_TOKEN"] if @github_personal_token.blank?
|
34
|
+
|
35
|
+
@github_personal_token
|
36
|
+
end
|
37
|
+
|
38
|
+
def post_extracted_info_endpoint
|
39
|
+
return ENV["REPO_ANALYZER_URL"] if @post_extracted_info_endpoint.blank?
|
40
|
+
|
41
|
+
@post_extracted_info_endpoint
|
42
|
+
end
|
43
|
+
|
44
|
+
def setup
|
45
|
+
yield self
|
46
|
+
require "repo_analyzer"
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
namespace :repo_analyzer do
|
2
|
+
desc "Extract repo info and post to defined endpoint"
|
3
|
+
task :analyze, [:repo_name] => :environment do |_t, args|
|
4
|
+
project_info = RepoAnalyzer::ExtractProjectInfoJob.perform_now(args.repo_name)
|
5
|
+
RepoAnalyzer::PostExtractedInfoJob.perform_now(args.repo_name, project_info)
|
6
|
+
end
|
7
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem"s version:
|
4
|
+
require "repo_analyzer/version"
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "repo_analyzer"
|
9
|
+
s.version = RepoAnalyzer::VERSION
|
10
|
+
s.authors = ["Platanus", "Leandro Segovia"]
|
11
|
+
s.email = ["rubygems@platan.us", "leandro@platan.us"]
|
12
|
+
s.homepage = "https://github.com/platanus/repo_analyzer"
|
13
|
+
s.summary = "Tool to extract technical debt"
|
14
|
+
s.description = "Rails engine to extract technical debt"
|
15
|
+
s.license = "MIT"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split($/).reject { |fn| fn.start_with? "spec" }
|
18
|
+
s.bindir = "exe"
|
19
|
+
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
s.test_files = Dir["spec/**/*"]
|
21
|
+
|
22
|
+
s.add_dependency "brakeman"
|
23
|
+
s.add_dependency "octokit", "~> 4.0"
|
24
|
+
s.add_dependency "rails", ">= 6.0"
|
25
|
+
s.add_dependency "rails_best_practices"
|
26
|
+
s.add_dependency "rubocop", "~> 1.9"
|
27
|
+
s.add_dependency "rubocop-performance"
|
28
|
+
s.add_dependency "rubocop-platanus", "~> 0.2"
|
29
|
+
s.add_dependency "rubocop-rails"
|
30
|
+
s.add_dependency "rubocop-rspec", "~> 2.2"
|
31
|
+
|
32
|
+
s.add_development_dependency "bundler", "~> 2.4.3"
|
33
|
+
s.add_development_dependency "coveralls"
|
34
|
+
s.add_development_dependency "factory_bot_rails"
|
35
|
+
s.add_development_dependency "guard-rspec"
|
36
|
+
s.add_development_dependency "pry"
|
37
|
+
s.add_development_dependency "pry-rails"
|
38
|
+
s.add_development_dependency "rspec_junit_formatter"
|
39
|
+
s.add_development_dependency "rspec-rails"
|
40
|
+
s.add_development_dependency "rubocop", "~> 1.9"
|
41
|
+
s.add_development_dependency "rubocop-rails"
|
42
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# Hola!
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
build:
|
4
|
+
working_directory: ~/app
|
5
|
+
|
6
|
+
docker:
|
7
|
+
- image: platanus/compose:1.22.0
|
8
|
+
|
9
|
+
steps:
|
10
|
+
- checkout
|
11
|
+
- setup_remote_docker
|
12
|
+
|
13
|
+
- run: docker info
|
14
|
+
- run: docker-compose -f docker-compose.ci.yml pull
|
15
|
+
- run: docker-compose -f docker-compose.ci.yml build test
|
16
|
+
- run: bin/cibuild services
|
17
|
+
- run: bin/cibuild deps
|
18
|
+
|
19
|
+
- run: bin/cibuild db
|
20
|
+
- run: bin/cibuild tests
|
21
|
+
- run: bin/cibuild js_tests
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,152 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
ruby-image: &ruby-image cimg/ruby:2.7
|
4
|
+
postgres-image: &postgres-image postgres:11.3
|
5
|
+
env-vars: &env-vars
|
6
|
+
BUNDLE_JOBS: 4
|
7
|
+
BUNDLE_PATH: vendor/bundle
|
8
|
+
RAILS_ENV: test
|
9
|
+
orbs:
|
10
|
+
browser-tools: circleci/browser-tools@1.1
|
11
|
+
|
12
|
+
executors:
|
13
|
+
test-executor:
|
14
|
+
docker:
|
15
|
+
- image: *ruby-image
|
16
|
+
environment: *env-vars
|
17
|
+
- image: *postgres-image
|
18
|
+
|
19
|
+
lint-executor:
|
20
|
+
docker:
|
21
|
+
- image: *ruby-image
|
22
|
+
environment: *env-vars
|
23
|
+
|
24
|
+
commands:
|
25
|
+
setup:
|
26
|
+
description: checkout code, restore cache, install dependencies, save cache
|
27
|
+
steps:
|
28
|
+
- checkout
|
29
|
+
|
30
|
+
- restore_cache:
|
31
|
+
keys:
|
32
|
+
- bundle-dependencies-{{ checksum "Gemfile.lock" }}
|
33
|
+
- bundle-dependencies-
|
34
|
+
|
35
|
+
- restore_cache:
|
36
|
+
keys:
|
37
|
+
- yarn-dependencies-{{ checksum "yarn.lock" }}
|
38
|
+
- yarn-dependencies-
|
39
|
+
|
40
|
+
- run:
|
41
|
+
name: Install reviewdog
|
42
|
+
command: |
|
43
|
+
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b ./bin
|
44
|
+
|
45
|
+
- run:
|
46
|
+
name: Install bundle dependencies
|
47
|
+
command: |
|
48
|
+
BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")
|
49
|
+
gem install bundler:$BUNDLER_VERSION
|
50
|
+
bundle _$(echo $BUNDLER_VERSION)_ install
|
51
|
+
|
52
|
+
- run: sudo apt-get update && sudo apt-get install ca-certificates
|
53
|
+
|
54
|
+
- run:
|
55
|
+
name: Install yarn dependencies
|
56
|
+
command: |
|
57
|
+
curl -sL https://deb.nodesource.com/setup_$(cat .node-version).x | sudo -E bash -
|
58
|
+
sudo apt-get install -y nodejs
|
59
|
+
curl -o- -sL https://yarnpkg.com/install.sh | bash
|
60
|
+
sudo ln -s $HOME/.yarn/bin/yarn /usr/local/bin/yarn
|
61
|
+
yarn install --frozen-lockfile
|
62
|
+
|
63
|
+
- save_cache:
|
64
|
+
key: bundle-dependencies-{{ checksum "Gemfile.lock" }}
|
65
|
+
paths:
|
66
|
+
- vendor/bundle
|
67
|
+
|
68
|
+
- save_cache:
|
69
|
+
key: yarn-dependencies-{{ checksum "yarn.lock" }}
|
70
|
+
paths:
|
71
|
+
- node_modules
|
72
|
+
|
73
|
+
jobs:
|
74
|
+
test:
|
75
|
+
executor: test-executor
|
76
|
+
steps:
|
77
|
+
- setup
|
78
|
+
- browser-tools/install-chrome
|
79
|
+
- browser-tools/install-chromedriver
|
80
|
+
|
81
|
+
- run:
|
82
|
+
name: Wait for postgres service
|
83
|
+
command: dockerize -wait tcp://localhost:5432 -timeout 1m
|
84
|
+
|
85
|
+
- run:
|
86
|
+
name: Setup database
|
87
|
+
command: bundle exec rails db:create db:schema:load
|
88
|
+
|
89
|
+
- run:
|
90
|
+
name: Run RSpec unit tests
|
91
|
+
command: |
|
92
|
+
RSPEC_JUNIT_ARGS="-r rspec_junit_formatter -f RspecJunitFormatter -o test_results/rspec.xml"
|
93
|
+
RSPEC_FORMAT_ARGS="-f progress --no-color -p 10"
|
94
|
+
bundle exec rspec spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
|
95
|
+
|
96
|
+
- run:
|
97
|
+
name: Run simplecov
|
98
|
+
shell: /bin/bash
|
99
|
+
command: |
|
100
|
+
cat coverage/coverage.txt | ./bin/reviewdog -reporter=github-pr-review -efm="%f:%l:%c: %m"
|
101
|
+
|
102
|
+
- run:
|
103
|
+
name: Run RSpec system tests
|
104
|
+
command: |
|
105
|
+
RSPEC_JUNIT_ARGS="-r rspec_junit_formatter -f RspecJunitFormatter -o test_results/rspec-system.xml"
|
106
|
+
RSPEC_FORMAT_ARGS="--tag type:system -f progress --no-color -p 10"
|
107
|
+
bundle exec rspec spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
|
108
|
+
|
109
|
+
- run:
|
110
|
+
name: Run jest
|
111
|
+
command: yarn run test
|
112
|
+
|
113
|
+
- store_test_results:
|
114
|
+
path: test_results
|
115
|
+
|
116
|
+
lint:
|
117
|
+
executor: lint-executor
|
118
|
+
steps:
|
119
|
+
- setup
|
120
|
+
|
121
|
+
- run:
|
122
|
+
name: Get files to lint
|
123
|
+
command: git diff origin/master --name-only --diff-filter=d > tmp/files_to_lint
|
124
|
+
|
125
|
+
- run:
|
126
|
+
name: Run rubocop
|
127
|
+
shell: /bin/bash
|
128
|
+
command: |
|
129
|
+
cat tmp/files_to_lint | grep -E '.+\.(rb)$' | xargs bundle exec rubocop --force-exclusion \
|
130
|
+
| ./bin/reviewdog -reporter=github-pr-review -f=rubocop
|
131
|
+
|
132
|
+
- run:
|
133
|
+
name: Run eslint
|
134
|
+
shell: /bin/bash
|
135
|
+
command: |
|
136
|
+
cat tmp/files_to_lint | grep -E '.+\.(js|jsx|vue)$' | xargs yarn run eslint \
|
137
|
+
| ./bin/reviewdog -reporter=github-pr-review -f=eslint
|
138
|
+
|
139
|
+
- run:
|
140
|
+
name: Run stylelint
|
141
|
+
shell: /bin/bash
|
142
|
+
command: |
|
143
|
+
cat tmp/files_to_lint | grep -E '.+\.(scss|css|less)$' | xargs yarn run stylelint \
|
144
|
+
| ./bin/reviewdog -reporter=github-pr-review -f=stylelint
|
145
|
+
|
146
|
+
workflows:
|
147
|
+
test_and_lint:
|
148
|
+
jobs:
|
149
|
+
- test:
|
150
|
+
context: org-global
|
151
|
+
- lint:
|
152
|
+
context: org-global
|
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in human_attributes.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
11
|
+
# your gem to rubygems.org.
|
12
|
+
|
13
|
+
# To use a debugger
|
14
|
+
# gem 'byebug', group: [:development, :test]
|