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.
You can use multiple assignment here and use .to_s instead of String()
There was a problem hiding this comment.
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 |
lib/rubycritic/commands/compare.rb
Outdated
| @files_affected = [] | ||
| @analysed_modules = [] | ||
| @number = 0 | ||
| @code_index_file_location = '' |
There was a problem hiding this comment.
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.
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.
Config.send(:"#{branch_type}_score") = score| end | ||
|
|
||
| def threshold_values_set? | ||
| Config.threshold_score > 0 |
There was a problem hiding this comment.
if threshold is nil this will fail with undefined method>' for nil:NilClass`
| true | ||
| elsif arg == 'feature_branch' | ||
| true | ||
| end |
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.
mention that this works only with -b
| end | ||
|
|
||
| def threshold_values_set? | ||
| Config.threshold_score > 0 |
| end | ||
|
|
||
| def update_build_number | ||
| build_file_location = '/tmp/build_count.txt' |
There was a problem hiding this comment.
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| |
| 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'), | ||
| ] | ||
| } |
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" |
lib/rubycritic/commands/compare.rb
Outdated
| end | ||
|
|
||
| def degraded_files | ||
| files_affected = [] |
There was a problem hiding this comment.
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}") |
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) } |
| 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") } |
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.
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" |
… 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.