-
Notifications
You must be signed in to change notification settings - Fork 1
Rubycritic compare b/w branches #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
… degraded the code quality
Pushing the status of the code and report location to gitlab using gitlab api
* Code refactoring, DRY * Comparing between branches in local without pr id.
1. Setting a new mode to compare between branches. 2. Moved the code changes to a seperate file. 3. Pushing comments on to pr. 4. Specs for analysed_module_collection.
Upgrade `parser` to `2.3.1.4`. One warning still left which comes from `parser`. Hopefully that is fixed in later versions.
Fix some ruby warnings thrown on rake test
1. Removed Gitlab,Github integrations. 2. Template Changes. 3. Options changes.
1. Added specs for compare module 2. Added threshold as an option in rubycritic before it was as app side configuration 3. Check for any uncommited changes
1. Removed redundant code. 2. Adding config so that browser doesn't open html report during test.
lib/rubycritic/cli/options.rb
Outdated
|
|
||
| opts.on('-b', '--branch BASE_BRANCH,FEATURE_BRANCH' , 'Set branches') do |branches| | ||
| self.base_branch = String(branches.split(',')[0].strip) | ||
| self.feature_branch = String(branches.split(',')[1].strip) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use multiple assignment here and use .to_s instead of String()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.base_branch, self.feature_branch = branches.split(',').map { |b| String(b.strip) }
lib/rubycritic/cli/options.rb
Outdated
|
|
||
| attr_accessor :mode, :root, :format, :deduplicate_symlinks, | ||
| :suppress_ratings, :minimum_score, :no_browser, :parser | ||
| :suppress_ratings, :minimum_score, :no_browser, :parser, :base_branch, :feature_branch, :threshold_score |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long
lib/rubycritic/commands/compare.rb
Outdated
| @files_affected = [] | ||
| @analysed_modules = [] | ||
| @number = 0 | ||
| @code_index_file_location = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these all variables used? If not remove them. Also give better names - eg number is not very intuitive. Also I don't prefer names with data structures like hash, array, etc.
| end | ||
|
|
||
| def update_build_number | ||
| build_file_location = '/tmp/build_count.txt' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mention the use of this count file as a comment above the method.
lib/rubycritic/commands/compare.rb
Outdated
| end | ||
|
|
||
| def set_scores(branch_type, score) | ||
| branch_type == 'base_branch' ? Config.base_branch_score = score : Config.feature_branch_score = score |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config.send(:"#{branch_type}_score") = score| end | ||
|
|
||
| def threshold_values_set? | ||
| Config.threshold_score > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if threshold is nil this will fail with undefined method>' for nil:NilClass`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix this
| true | ||
| elsif arg == 'feature_branch' | ||
| true | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this? 😳
1. Changes for stub in compare test file 2. Cleaning up compare.rb 3. Changes in option parsing
| -p, --path [PATH] Set path where report will be saved (tmp/rubycritic by default) | ||
| -b BASE_BRANCH,FEATURE_BRANCH, Set branches | ||
| --branch | ||
| -t [THRESHOLD_SCORE], Set a threshold score |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mention that this works only with -b
| end | ||
|
|
||
| def threshold_values_set? | ||
| Config.threshold_score > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix this
| end | ||
|
|
||
| def update_build_number | ||
| build_file_location = '/tmp/build_count.txt' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mention the use of this count file as a comment above the method.
lib/rubycritic/commands/compare.rb
Outdated
|
|
||
| def degraded_files | ||
| files_affected = [] | ||
| @feature_branch.each do |key, value| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use map instead of each
| let(:analysed_modules) { [RubyCritic::AnalysedModule.new(pathname: Pathname.new('test/samples/empty.rb'), name: 'Empty'), | ||
| RubyCritic::AnalysedModule.new(pathname: Pathname.new('test/samples/unparsable.rb'), name: 'Unparsable'), | ||
| ] | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use do-end for multi-line blocks.
Bump to v3.1.0
Add screenshots of new ui in README
|
@HemanthMudalaiah get this done quickly and raise PR on |
lib/rubycritic/commands/compare.rb
Outdated
|
|
||
| def build_details | ||
| details = "Base branch (#{Config.base_branch}) score: " + Config.base_branch_score.to_s + "\n" | ||
| details += "Feature branch (#{Config.feature_branch}) score: " + Config.feature_branch_score.to_s + "\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use multi-line string
lib/rubycritic/commands/compare.rb
Outdated
| end | ||
|
|
||
| def degraded_files | ||
| files_affected = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this, return array from map
lib/rubycritic/commands/compare.rb
Outdated
| end | ||
|
|
||
| def build_cost_hash(cost_hash, analysed_modules) | ||
| complexity_hash = eval("@#{cost_hash}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove eval
lib/rubycritic/commands/compare.rb
Outdated
|
|
||
| def build_cost_hash(cost_hash, analysed_modules) | ||
| complexity_hash = eval("@#{cost_hash}") | ||
| analysed_modules.map { |analysed_module| complexity_hash.merge!(:"#{analysed_module.name}" => analysed_module.cost) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line is too long
| class Git < Base | ||
| def self.switch_branch(branch) | ||
| File.open('test/samples/compare_file.rb', 'w') { |file| file.truncate(0) } | ||
| File.open('test/samples/compare_file.rb', 'w') { |file| file.puts File.readlines("test/samples/#{branch}_file.rb") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long
1. Generating report for all modified files in the feature branch instead of degraded files as before. 2. Removing methods related to get degraded files. 3. Fixing specs due the above changse.
lib/rubycritic/commands/compare.rb
Outdated
| def execute | ||
| Config.no_browser = true | ||
| compare_branches | ||
| status_reporter.score = (Config.base_branch_score - Config.feature_branch_score).abs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tell whether score has increased or decreased in the console output.
lib/rubycritic/commands/compare.rb
Outdated
| # create a txt file with the branch score details | ||
| def build_details | ||
| details = "Base branch (#{Config.base_branch}) score: " + Config.base_branch_score.to_s + "\n"\ | ||
| "Feature branch (#{Config.feature_branch}) score: " + Config.feature_branch_score.to_s + "\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use string interpolation
… degraded the code quality
Pushing the status of the code and report location to gitlab using gitlab api
* Code refactoring, DRY * Comparing between branches in local without pr id.
1. Setting a new mode to compare between branches. 2. Moved the code changes to a seperate file. 3. Pushing comments on to pr. 4. Specs for analysed_module_collection.
1. Removed Gitlab,Github integrations. 2. Template Changes. 3. Options changes.
1. Added specs for compare module 2. Added threshold as an option in rubycritic before it was as app side configuration 3. Check for any uncommited changes
1. Removed redundant code. 2. Adding config so that browser doesn't open html report during test.
1. Changes for stub in compare test file 2. Cleaning up compare.rb 3. Changes in option parsing
1. Generating report for all modified files in the feature branch instead of degraded files as before. 2. Removing methods related to get degraded files. 3. Fixing specs due the above changse.
|
Something went wrong with the rebase. It contains commits from others as well. |
No description provided.