Skip to content

Commit

Permalink
[api] disarm the code quality test a bit
Browse files Browse the repository at this point in the history
- raise the limit for the blacklist to 50, if all our functions would be below
50 I would be happy enough :)

- do not fail if the score lowers
  • Loading branch information
coolo committed Sep 23, 2013
1 parent 86df861 commit ca351ef
Showing 1 changed file with 11 additions and 36 deletions.
47 changes: 11 additions & 36 deletions src/api/test/unit/code_quality_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,15 @@ def setup
BlackList = {
'ApplicationController#extract_ldap_user' => 123.29,
'ApplicationController#extract_proxy_user' => 65.48,
'ApplicationController#check_for_anonymous_user' => 48.72,
'ApplicationController#forward_from_backend' => 57.96,
'ApplicationController#render_error' => 47.11,
'ArchitecturesController#index' => 55.94,
'Attrib#update_from_xml' => 62.88,
'AttributeController#attribute_definition' => 87.7,
'AttributeController#cmd_attribute' => 44.22,
'AttributeController#delete_attribute' => 42.24,
'AttributeController#find_attribute_container' => 62.42,
'AttributeController#namespace_definition' => 64.52,
'BsRequest#change_review_state' => 177.4,
'BsRequest#change_state' => 43.81,
'BsRequest#check_newstate!' => 84.89,
'BsRequest#events' => 143.76,
'BsRequest#remove_reviews' => 44.57,
'BsRequest#render_xml' => 42.98,
'BsRequest#webui_actions' => 130.13,
'BsRequest::new_from_xml' => 126.34,
'BsRequestAction#check_action_permission!' => 221.25,
Expand All @@ -98,42 +91,30 @@ def setup
'FullTextSearch#search' => 69.44,
'HasAttributes#check_attrib!' => 52.45,
'HasAttributes#render_main_attributes' => 81.58,
'HasRelationships#update_generic_relationships' => 42.42,
'Issue#render_body' => 52.78,
'IssueTracker#update_issues' => 60.49,
'IssueTrackersController#create' => 53.05,
'IssueTrackersController#update' => 100.78,
'Maintainership#extract_maintainer' => 144.49,
'Maintainership#find_assignees' => 64.17,
'Maintainership#find_containers' => 42.72,
'MaintenanceHelper#create_new_maintenance_incident' => 64.93,
'MaintenanceHelper#do_branch' => 1118,
'MaintenanceHelper#release_package' => 227.71,
'MaintenanceIncident#getUpdateinfoId' => 151.95,
'MaintenanceIncident#project_name' => 49.41,
'PackInfo#to_xml' => 63.64,
'Package#find_linking_packages' => 40.68,
'Package#resolve_devel_package' => 52.33,
'Package::get_by_project_and_name' => 42.13,
'PersonController#change_password' => 45.67,
'PersonController#internal_register' => 185.66,
'PersonController#userinfo' => 139.67,
'Project#branch_to_repositories_from' => 117.4,
'Project#cleanup_before_destroy' => 67.17,
'Project#do_project_release' => 46.59,
'Project#expand_flags' => 48.97,
'Project#update_from_xml' => 456.54,
'Project#update_product_autopackages' => 47.69,
'Project::check_access?' => 54.05,
'Project::get_by_name' => 53.44,
'ProjectStatusCalculator#calc_status' => 74.59,
'ProjectStatusCalculator#update_jobhistory' => 43.21,
'PublicController#binary_packages' => 134.24,
'Relationship#check_sanity' => 48.62,
'Repository#cleanup_before_destroy' => 85.53,
'RequestController#check_request_change' => 257.26,
'RequestController#command_changestate' => 190.9,
'RequestController#command_diff' => 47.51,
'RequestController#create_create' => 110.65,
'RequestController#render_request_collection' => 92.82,
'SearchController#find_attribute' => 104.54,
Expand All @@ -143,38 +124,26 @@ def setup
'SourceController#delete_project' => 64.16,
'SourceController#package_command' => 65.31,
'SourceController#package_command_copy' => 64.36,
'SourceController#package_command_release' => 41.75,
'SourceController#package_meta' => 95.53,
'SourceController#private_remove_repositories' => 40.37,
'SourceController#project_command' => 42.44,
'SourceController#project_command_copy' => 140.04,
'SourceController#project_command_set_flag' => 53.57,
'SourceController#project_command_undelete' => 58.11,
'SourceController#project_command_unlock' => 47.79,
'SourceController#update_project_meta' => 139.28,
'SourceController#show_project' => 88.97,
'SourceController#update_file' => 97.26,
'SourceController#verify_repos_match!' => 52.26,
'StatisticsController#active_request_creators' => 71.14,
'StatisticsController#rating' => 57.46,
'StatusHelper::resample' => 46.25,
'StatusHistoryRescaler#cleanup' => 43.59,
'SubmitRequestSourceDiff::ActionSourceDiffer#diff_for_source' => 60.19,
'TagController#package_tags' => 42.02,
'TagController#project_tags' => 42.13,
'TagController#tagcloud' => 68.37,
'TagController#update_tags_by_object_and_user' => 67.76,
'Tagcloud#initialize' => 41.73,
'User#can_create_attribute_in?' => 57.78,
'User#has_local_permission?' => 41.2,
'User#state_transition_allowed?' => 100.14,
'UserLdapStrategy::find_with_ldap' => 181.11,
'UserLdapStrategy::initialize_ldap_con' => 64.05,
'UserLdapStrategy::new_entry_ldap' => 45.07,
'UserLdapStrategy::render_grouplist_ldap' => 100.3,
'UserLdapStrategy::update_entry_ldap' => 59.56,
'Webui::ProjectsController#status_check_package' => 211.04,
'Webui::ProjectsController#status_filter_packages' => 47.19,
'Webui::ProjectsController#status_check_package' => 200,
'WizardController#package_wizard' => 135.16,
}

Expand All @@ -190,7 +159,7 @@ def setup
mismatches = []

flog.each_by_score do |class_method, score, call_list|
break if score < 40 # they are sorted
break if score < 50 # they are sorted
next if class_method.end_with? "#none"
score = Integer(score * 100)
score = score / Float(100)
Expand All @@ -200,12 +169,18 @@ def setup
mismatches << "'#{class_method}' => #{score}, is not in the blacklist"
next
end
# don't want to be too strict here
# don't want to be too strict here
next if (oldscore-score).abs < 2
mismatches << " '#{class_method}' => #{score}, # oldscore=#{oldscore}"
error = " '#{class_method}' => #{score}, # oldscore=#{oldscore}"
if score > oldscore
mismatches << error
else
# scare them but don't fail
puts error
end
end

assert mismatches.empty?, mismatches.join("\n")
assert black.empty?, "Some functions are no longer complex and need to removed from black list - #{black.keys.inspect}"
puts "Some functions are no longer complex and need to removed from black list - #{black.keys.inspect}" unless black.empty?
end
end

0 comments on commit ca351ef

Please sign in to comment.