Skip to content

Conversation

@HemanthMudalaiah
Copy link

No description provided.

Hemant Gowda and others added 14 commits October 10, 2016 17:34
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.

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)

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()

Copy link

@tejasbubane tejasbubane Nov 18, 2016

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) }


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long

@files_affected = []
@analysed_modules = []
@number = 0
@code_index_file_location = ''

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'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this?

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.

end

def set_scores(branch_type, score)
branch_type == 'base_branch' ? Config.base_branch_score = score : Config.feature_branch_score = score

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

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`

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

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

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

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'

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.


def degraded_files
files_affected = []
@feature_branch.each do |key, value|

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'),
]
}

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.

@vijayanandnandam
Copy link

@HemanthMudalaiah get this done quickly and raise PR on rubycritic


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"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use multi-line string

end

def degraded_files
files_affected = []

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

end

def build_cost_hash(cost_hash, analysed_modules)
complexity_hash = eval("@#{cost_hash}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove eval


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) }

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") }

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.
def execute
Config.no_browser = true
compare_branches
status_reporter.score = (Config.base_branch_score - Config.feature_branch_score).abs

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.

# 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"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use string interpolation

Hemant Gowda added 20 commits November 25, 2016 13:14
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.
@tejasbubane
Copy link

Something went wrong with the rebase. It contains commits from others as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants